PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.databases.mysql > How do I find out exactly why a query is taking so long?
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
How do I find out exactly why a query is taking so long?

Réponse
 
LinkBack Outils de la discussion
Vieux 26/09/2007, 15h46   #1
Brian Kendig
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut How do I find out exactly why a query is taking so long?

When I query against a view (SELECT * FROM myView) in my test
environment, it comes back immediately. When I do the same query in my
production environment, it takes 2-3 minutes to come back with the
same data.

The environments are running on identical hardware with identical
software revisions (MySQL 5.1.17 on Linux) and almost-identical data
(we refreshed the test environment with production data a few days
ago).

How can I diagnose this, and find out why the query is taking so long
in production?

  Réponse avec citation
Vieux 26/09/2007, 16h23   #2
Brian Kendig
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: How do I find out exactly why a query is taking so long?

On Sep 26, 9:46 am, Brian Kendig <br...@enchanter.net> wrote:
> When I query against a view (SELECT * FROM myView) in my test
> environment, it comes back immediately. When I do the same query in my
> production environment, it takes 2-3 minutes to come back with the
> same data.


We solved the problem - the buffer pool size on the production server,
where the query was running slowly, was set to 256MB. When we
*reduced* this to 128MB, the time required by the query went from 199
seconds down to a tenth of a second.

Yes, it's counterintuitive that reducing the size of the buffer would
speed things up, but this is a server with 2GB RAM being shared by a
few vservers, and we're figuring that the host was having trouble with
the amount of memory the database vserver was trying to use.


  Réponse avec citation
Vieux 26/09/2007, 17h57   #3
ZeldorBlat
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: How do I find out exactly why a query is taking so long?

On Sep 26, 10:23 am, Brian Kendig <br...@enchanter.net> wrote:
> On Sep 26, 9:46 am, Brian Kendig <br...@enchanter.net> wrote:
>
> > When I query against a view (SELECT * FROM myView) in my test
> > environment, it comes back immediately. When I do the same query in my
> > production environment, it takes 2-3 minutes to come back with the
> > same data.

>
> We solved the problem - the buffer pool size on the production server,
> where the query was running slowly, was set to 256MB. When we
> *reduced* this to 128MB, the time required by the query went from 199
> seconds down to a tenth of a second.
>
> Yes, it's counterintuitive that reducing the size of the buffer would
> speed things up, but this is a server with 2GB RAM being shared by a
> few vservers, and we're figuring that the host was having trouble with
> the amount of memory the database vserver was trying to use.


It is counterintuitive and it isn't. I've seen cases where the
increased buffer pool causes the optimizer to come up with a sub-
optimal query plan. In one that I saw, the optimizer thought that,
because of the increased memory available, it should load an entire
table into memory first (and it was a fairly large table) and then
join to the worktable rather than join to the table itself. This
caused the query to run excruciatingly slow.

  Réponse avec citation
Vieux 27/09/2007, 06h29   #4
-Lost
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: How do I find out exactly why a query is taking so long?

Response from ZeldorBlat <zeldorblat@gmail.com>:

> On Sep 26, 10:23 am, Brian Kendig <br...@enchanter.net> wrote:
>> On Sep 26, 9:46 am, Brian Kendig <br...@enchanter.net> wrote:
>>
>> > When I query against a view (SELECT * FROM myView) in my test
>> > environment, it comes back immediately. When I do the same
>> > query in my production environment, it takes 2-3 minutes to
>> > come back with the same data.

>>
>> We solved the problem - the buffer pool size on the production
>> server, where the query was running slowly, was set to 256MB.
>> When we *reduced* this to 128MB, the time required by the query
>> went from 199 seconds down to a tenth of a second.
>>
>> Yes, it's counterintuitive that reducing the size of the buffer
>> would speed things up, but this is a server with 2GB RAM being
>> shared by a few vservers, and we're figuring that the host was
>> having trouble with the amount of memory the database vserver was
>> trying to use.

>
> It is counterintuitive and it isn't. I've seen cases where the
> increased buffer pool causes the optimizer to come up with a sub-
> optimal query plan. In one that I saw, the optimizer thought
> that, because of the increased memory available, it should load an
> entire table into memory first (and it was a fairly large table)
> and then join to the worktable rather than join to the table
> itself. This caused the query to run excruciatingly slow.


Granted it may be due to lack of real-world experience, but I have
never understood the recommendation that the InnoDB buffer pool
should be 75% of available RAM.

That is a 1.5GB buffer in the above example.

I can only hope that it was the ideal situation for a dedicated MySQL
server.

--
-Lost
Remove the extra words to reply by e-mail. Don't e-mail me. I am
kidding. No I am not.
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 00h59.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,11046 seconds with 12 queries