Re: ODBC and inappropriate select *

From: Scott Marlowe <smarlowe(at)g2switchworks(dot)com>
To: Steve Crawford <scrawford(at)pinpointresearch(dot)com>
Cc: "pgsql-general postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: ODBC and inappropriate select *
Date: 2005-09-01 20:01:17
Message-ID: 1125604877.28179.173.camel@state.g2switchworks.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, 2005-09-01 at 13:58, Steve Crawford wrote:
> We have an old legacy app that connects to our PostgreSQL (7.4.6)
> database. It is an old Visual Basic/Business Objects (VB 6.0, MDAC
> 2.5) program that selects a group of records and locks them by
> setting a field to an "in-progress" status. The user then works on
> those records and when done, returns the batch.
>
> We are having a terrible performance problem that we have traced to
> inappropriate queries being sent to the server. Whenever a user
> requests a batch, the app first runs the appropriate query with a
> where clause. This query returns virtually instantly.
>
> Unfortunately, it follows this by a "select * from tablename" which
> may return well over 100,000 records. Even this query run via psql on
> my linux desktop takes less than a second but apparently the VB app
> has trouble choking down all the unnecessary data it has requested
> leaving the user waiting 15 seconds or more for the update.

Is that select * being used to COUNT the number of rows? If so, then do
a "select count(*)" which will take the db engine about as long, but it
won't need to transfer the data across.

If a select * is really needed, then look at at least using a cursor.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Cristian Prieto 2005-09-01 20:10:04 ECPG examples...
Previous Message Michael Fuhr 2005-09-01 19:23:36 Re: query