Skip site navigation (1) Skip section navigation (2)

Re: Performance of multiple queries?

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Leif K-Brooks <eurleif(at)gmail(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Performance of multiple queries?
Date: 2005-04-21 16:59:32
Message-ID: 20050421165932.GA10450@wolff.to (view raw or flat)
Thread:
Lists: pgsql-novice
On Thu, Apr 21, 2005 at 05:33:12 -0400,
  Leif K-Brooks <eurleif(at)gmail(dot)com> wrote:
> I'm wondering about the performance of using one query versus several.
> For instance, how much slower would several queries be:
> 
> SELECT name FROM table WHERE id=123;
> SELECT value FROM table WHERE id=123;
> SELECT type FROM table WHERE id=123;
> 
> As compared to one larger equivalent query:
> 
> SELECT name, value, type FROM table WHERE id=123;

You can probably expect it will take three times as long to do the three
queries instead of one. Significant exceptions would be if one of the columns
had a very large (in bytes) value so that time was dominated by how long
it took to transmit that value and if you don't expect the needed data
to be available from postgres' or the OS' cache for the first queries.

In response to

pgsql-novice by date

Next:From: Keith WorthingtonDate: 2005-04-21 19:00:28
Subject: Upgrade from 8.0.0 to 8.0.2
Previous:From: Sean DavisDate: 2005-04-21 16:06:00
Subject: Re: Adding perl

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group