Re: Delphi 3/Informix too slow!!!
Posted in 1998
Topics: Connectivity: ODBC / JDBC / .NET, Jobs, Consulting & Announcements
In article <6jsdlo$ukk$1@duke.telepac.pt>, fasoft@mail.telepac.pt (Fasoft) wrote: > > the Informix SE v 7.1. The ODBC is from Informix (Informix-CLI v 2.50TD2). First optimization, use Delphi Client/Server and ditch the ODBC driver. The native driver is much faster. > > The problem is that activating the tables (table.Active := True) is > TOO MUCH SLOW. The same to Update/Delete/Insert ... > The tables are quite large (>10000 records). Optimization 2, use TQuerys, which allow you to restrict both the number of fields and number of rows that you're retrieving from the DB. The thing to understand here is that with a TTable, it attempts to cache the ENTIRE dataset locally before it reports that the open is completed. > How can i speed up my application. Other things that you can do, be sure that you are funneling all of your database connections through a TDatabase component, if not, each DB access component, such as table or query, represents a separate connection to the DB, each with the overhead of logging in, and it will use up a connection liscense, if you've liscensed it that way. With the TDatabase, one login, and one shared connection. Also, depending on how your app is structured, you may want to set it up so that the TDatabase maintains the connection even when all other DB connections are closed, so you don't have the overhead of logging in and out for each time you open up your query. 2. Prepare your queries. The way things work in Delphi in CS mode is that when you open the TQuery, the SQL is sent acrossed the wire, compiled at the host, parameters resolved, run, then all the resources are released when you close the query. If you are going to hit the database repeatedly then calling prepare you change this to send and compile once, then resolve and run until such time as you call unprepare, or close the entire session. You can as much as double your speed when doing this. 3. Use Cached updates. When you use a TTable, or a TQuery with a live result set,(which is more or less the same as using a TTable) then Delphi dynamically generates SQL to do your updates...and often doesn't do a very good job of it, with cached updates YOU write the update, delete, and insert SQL, all of the changes are done in a local cache, then once you've completed all the changes, on multiple records even, you call TDatabase.ApplyUpdates and it calls your optimized and prepared SQL on only those records that have been marked as dirty. Whew! So there are a lot of things that you can do to speed up your application, and they work not only with Informix, but Oracle, DB2, and a lot of others as well. Anyway, I hope this helps. Your resident Delphi fanatic. Mike Mormando BEST Consultants -----== Posted via Deja News, The Leader in Internet Discussion ==----- http://www.dejanews.com/ Now offering spam-free web-based newsreading