Re: Any better plan for this query?..

From: Richard Huxton <dev(at)archonet(dot)com>
To: Dimitri <dimitrik(dot)fr(at)gmail(dot)com>
Cc: Merlin Moncure <mmoncure(at)gmail(dot)com>, PostgreSQL Performance <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Any better plan for this query?..
Date: 2009-05-06 12:53:45
Message-ID: 4A018859.8030000@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Dimitri wrote:
> I'll try to answer all mails at once :-))
>
> - query is running fully in RAM, no I/O, no network, only CPU time
>
> - looping 100 times the same query gives 132ms total time (~1.32ms per
> query), while it's 44ms on InnoDB (~0.44ms per query)

Well, assuming you're happy that PG is tuned reasonably for your machine
and that MySQL's query cache isn't returning the results here it looks
like MySQL is faster for this particular query.

The only obvious place there could be a big gain is with the hashing
algorithm. If you remove the ORDER BY and the query-time doesn't fall by
much then it's the hash phase.

The other thing to try is to alter the query to be a SELECT count(*)
rather than returning rows - that will let you measure the time to
transfer the result rows.

--
Richard Huxton
Archonet Ltd

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Kenneth Marshall 2009-05-06 12:58:55 Re: Any better plan for this query?..
Previous Message Dimitri 2009-05-06 12:49:23 Re: Any better plan for this query?..