Re: Slow transfer speeds - Mailing list pgsql-odbc

From greg.campbell@us.michelin.com
Subject Re: Slow transfer speeds
Date
Msg-id OFC40411F8.8B979E65-ON852571C3.0065A88A-852571C3.0065D61A@michelin.com
Whole thread Raw
In response to Slow transfer speeds  (hansell baran <hansellb@yahoo.com>)
List pgsql-odbc

You are probably stuck if you are getting the same results with pgAdmin III as with Access.

That said, the normal DBA steps for speed optimization still can shed light.

Check the application
1. You did not provide quite enough sample of your ADO code, if that is what you are using.
Typically you will want to test the effect of:
-using a Server side cursor (rs.CursorLocation = adUseServer)
-forcing ForwardOnly /ReadOnly cursors (not Keyset cursoring) ..rs.open sql, conn, adOpenForwardOnly, adOpenReadonly, adCmdText
-forcing a forward only cursor will give control back to the program sooner, but will not have a RecordCount, (all the records are not returned to the buffer necessarily,... just the cursor as a pointer).
If you want all the records back, or a RecordCount before control returns to your program use adOpenSnapshot.
There is a difference between speed and perceived responsiveness, (see the CacheSize, CursorType ...adOpenSnaphost, adOpenForwardOnly MSDN documentation for details)
2. There is also the matter of how many records are fetched at a time rs.CacheSize (the default is 1 but can be raised effectively to about 16000).

Check the Driver
3. You did not specify which pgodbc driver version you are testing with. I believe 08.02.02 is recommended.
4. Check the UseDeclareFetch setting (as you have already done.)
5. Check for Logging

Check the Database
6. Check data types. When linked as tables, make sure Access understand your float8 is the same type as its Double. You don't want to spend unnecessary time on type translations.
7. Much performance hinges on structure at the database, appropriate primary keys, and foreign keys, data types, etc.
8. If there are many joins to be done, the joins should be done in a VIEW on the server to eliminate optimization cycles.
9. You might also want to explore PostgreSQL functions (stored procedures), again for the elimination of optimization cycles having to do with parsing your query.
10. Check for how much logging is going on.


Did I mention that you are probably stuck if you get the same results with pgAdmin as with Access. I think pgAdmin doesn't even use the pgodbc driver, it uses its own socket to socket connection and the pglib, (last I looked that is).


630 seconds (over 15 minutes for one half million row query.... geez).



Greg Campbell ENG-ASE/Michelin US5
Lexington, South Carolina
803-951-5561, x75561
Fax: 803-951-5531
greg.campbell@us.michelin.com

Inactive hide details for hansell baran <hansellb@yahoo.com>hansell baran <hansellb@yahoo.com>


          hansell baran <hansellb@yahoo.com>
          Sent by: pgsql-odbc-owner@postgresql.org

          08/07/2006 13:24


To

pgsql-odbc@postgresql.org

cc


Subject

[ODBC] Slow transfer speeds

Hi. I'm new at using PostgreSQL. I have found posts related to this one but there is not a definite answer or solution. Here it goes.
Where I work, all databases were built with MS Access. The Access files are hosted by computers with Windows 2000 and Windows XP. A new server is on its way and only Open Source Software is going to be installed. The OS is going to be SUSE Linux 10.1 and we are making comparisons between MySQL, PostgreSQL and MS Access. We installed MySQL and PostgreSQL on both SUSE and Windows XP (MySQL & PostgreSQL DO NOT run at the same time)(There is one HDD for Windows and one for Linux)
The "Test Server" in which we install the DBMS has the following characteristics:

CPU speed = 1.3 GHz
RAM = 512 MB
HDD = 40 GB

The biggest table has 544371 rows(tuples?) with 55 rows. All fields are float8. Only 1 is varchar(255) and 1 timestamp.
We query the MS Access databases through Visual Basic Programs and ODBC Drivers. We made a Visual Basic program that uses ADO to connect to ALL three DBMS using ODBC drivers.

When we run the following query "SELECT * FROM big_table", we get the following resutls:

MS Access
- Execution time ~ 51 seconds (Depending on the client machine, it can go as low as 20 seconds)
- Network Utilization ~ 75 Mbps (According to Windows Task Manager)

MySQL 5.0(under Windows)
- Execution time ~ 630 seconds
- Network Utilization ~ 8 Mbps

PostgreSQL 8.1(under Windows)
- Execution time ~ 290 seconds)
- Network Utilization ~ 13 Mbps


MS Access (under Linux. MS Access files are in the Linux computer which has the SAMBA server running. The client computer has a mapped network drive that conects to the Linux files.)
- Execution time ~ 55 seconds (Depending on the client machine, it can go as low as 20 seconds)
- Network Utilization ~ 70 Mbps (According to Windows Task Manager)

MySQL 5.0(under Linux)
- Execution time ~ 440 seconds
- Network Utilization ~ 11 Mbps

PostgreSQL 8.1(under Linux)
- Execution time ~ 180 seconds)
- Network Utilization ~ 18 Mbps

Due to the fact that the query returns a lot of rows, I cannot use the ODBC driver with the "Use Declare/Fetch" option disabled. If I run the query with this option disabled, the transfer speed goes up to about 20 Mpbs (PostgreSQL in Windows) and ~35 Mbps (PostgreSQL in Linux) (The transfer speed never goes beyond 40 Mbps even if we query from several clients at the same time. If we query MS Access from several machines, the transfer speed goes almost to 85 Mbps. Obviously, these simultaneous querys run slower). The problem with running the query with the "Use Declare/Fetch" option disabled is that the client computer shows an error saying "Out of memory while reading tuples".

Very different results are obtained if a the query "SELECT * from big_table ORDER BY "some_column"". In this scenario PostgreSQL is faster than MS Access or MySQL by more than 100 seconds. Transfer speed, however, transfer speed is still slower for PostgreSQL than for MS Access.

We have run many other queries (not complex, at most nesting of 5 inner joins) and MS Access is always faster. We have seen by looking at the network activity in the Windows Task Manager that the main problem is the transfer speed. We also have noticed that MS Access quickly downloads the file that has the necesary information and works on it locally on the client computer. The queries, obviously, run faster if the client computer has more resources (CPU speed, RAM, etc.). The fact that the client computer does not use any resource to execute the query, only to receive the results, is one big plus for PostgreSQL (we think). We need,however, to improve the performance of the queries that return a lot of rows because those are the most used queries.

We searched the postgresql archives, mailing lists, etc. and have tried changing the parameters of the PostgreSQL server(both on Linux and Windows)(We also tried with the default parameters) and changing the parameters of the ODBC driver as suggested. We still get aproximately the same results. We have even changed some TCP/IP parameters(only in Windows) but no improvement.

We have turned off all tracings, logs, and debugs of the ODBC driver. The behaviour is the same when querying from pgAdmin III.

To get to the point: Is this problem with the transfer rates a PostgreSQL server/PostgresQL ODBC driver limitation?
Is there a way to increase the transfer rates?

Thank you very much for any help received!

Hansell E. Baran Altuve


Yahoo! Messenger with Voice. Make PC-to-Phone Calls to the US (and 30+ countries) for 2¢/min or less.

Attachment

pgsql-odbc by date:

Previous
From: hansell baran
Date:
Subject: Slow transfer speeds
Next
From: Patrick Hatcher
Date:
Subject: Re: PGAPI_SetPos error