This is a discussion on Performance of multiple queries? within the pgsql Novice forums, part of the PostgreSQL category; --> I'm wondering about the performance of using one query versus several. For instance, how much slower would several queries ...
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| 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; It would be immensely easier for my application to use multiple small queries so that it wouldn't need to worry about invalidating a cache after a period of time, but if the performance hit would be too large, I suppose I'll bite the bullet and write the annoying caching code. ---------------------------(end of broadcast)--------------------------- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faq |
| ||||
| On Thu, Apr 21, 2005 at 05:33:12 -0400, Leif K-Brooks <eurleif@gmail.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. ---------------------------(end of broadcast)--------------------------- TIP 6: Have you searched our list archives? http://archives.postgresql.org |