Additional
AnyDAC for Delphi 5.0 TADTable with live data window
Posted by Support [May 05, 2011]
The AnyDAC for Delphi v 5 introduces the TADTable with live data window. That makes TADTable fully compatible with TTable and enables TADTable to work with extremely large data volumes.

General 

TADTable Before AnyDAC v5 the TADTable was a TADQuery with TableName to SELECT * FROM TableName translator. Although TADQuery is the right tool for client-server development, many AnyDAC customers still need old smart BDE TTable but for AnyDAC. Are you in the same boat ? Smile

"So, what is good in the TTable ?", you may ask. It never fetches all records using single result set. It creates a live window into the table records. The window contains comparably small number of records (~200). The window is moving in the table data, when the program is navigating in the dataset. That gives you ability to work with millions of records without feching them all to the client and without the need to reopen query to refresh dataset.

 

"But where is a trick ?", you may ask again. As I sayd the TADQuery is the right tool for the client-server development, as it performs exactly the query you have specified with the good restricting WHERE, with limited SELECT list, etc. And TTable and now TADTable generate different queries behind the scena to implement the live window. That gives more work to the DBMS but makes you happy with how fast you can now go to the dataset bottom or just open the dataset.

Implementation

Because many our customers are in need for such TADTable for successful BDE to AnyDAC migration, we implemented it. The TADTable API remains mostly unchanged, but internals were reworked completely. Comparing to "old" TADTable we got:

 

  • ability to scroll through extremely large tables without delays at jumping to last record or how else. Tested on 1M of records.
  • Locate, GotoKey, ApplyRange, bookmarks and similar operations work with the live data. IOW, are server side.
  • filtering works with live data. IOW, is server side.

 

The TADTable generates a SELECT statements basing on its properties and send it to a DBMS. The TADTable has two main operation modes:

 

  • live data window mode. In this mode AnyDAC queries and keep in memory only 2 * FetchOptions.RowsetSize of records. The Filter property, range filtering, IndexFieldNames and IndexName properties, Locate and Lookup methods, key locating, setting RecNo are performed by additional SELECT commands or by setting additional phrases for the main SELECT command. That allows to open and work with the very large tables without serious delays and memory usage.
  • standard mode. This mode is similar to TADQuery. TADTable generates a single SELECT command and uses the result set to walk through table records.

 

The live data window mode is used when the following conditions are met, otherwise the standard mode is used:

 

 

The mode may be changed only when TADTable is inactive. Consequently, for example, the CachedUpdates may be changed only when table is inactive. In general, to make the live data window working effectively and correctly the TADTable requires:

 

  • a primary or unique key to be defined for a table and accessible to TADTable. See Unique Identifying Fields for more details.
  • a database sort order should match a client side sort order. The FormatOptions.SortLocale and SortOptions may be used to adjust the client side sort order.

 

Additionally, the performance may be improved by setting FetchOptions.LiveWindowMode to wmApproximate.

Behind the scene 

And few code sample showing how this works. Here we open the TADTable and jump to the last record:

 
ADTable1.TableName := 'Orders';
ADTable1.Open;
ADTable1.Last;
// -> SELECT * FROM "Orders" ORDER BY OrderID DESC {limit 100}

 

And perform Locate:

 
ADTable1.Locate('OrderID', 100, []);
// -> SELECT * FROM "Orders" WHERE OrderID = :OrderID ORDER BY OrderID ASC {limit 1}

 

Here {limit} is AnyDAC escape sequence. Note, to work properly TADTable requires primary key to be defined for the table. Also to make TADTable working effectively, the database programmer should create required indexes. To see queries which TADTable sends to a DB, enable tracing output for connection.

 

Also note, GetCustomOrderBy method was removed, because now TADTable always builds the ORDER BY phrase and it cannot be changed freely.

Afterwords

I want to thank MAD for helping us to implement new functionality and for his valuable remarks regarding TADTable !

 

The new functionality soon will enter into beta testing. If you have an active AnyDAC subscription and would like to participate in AnyDAC v5 beta testing, please contact This e-mail address is being protected from spam bots, you need JavaScript enabled to view it .


LIST OF COMMENTS


1/9. Good News
Posted by Rolphy Reyes - May 05, 2011
Website
Hi, Can you tell us What changes has TADQuery in this new version?

2/9. The changes
Posted by Support - May 07, 2011
Website

Hello

TADQuery itself will not get any major changes. But TADQuery is an "iceberg tip". A lot of other things "below water" will get valuable additions and improvements. Are you looking for some specific changes ?


3/9. Good News
Posted by RReyes - May 08, 2011
Website
Hi, Right now, I'm ok with TADQuery. You just starting the suggestion about Server Side Filtering.

4/9. Server Side Filtering
Posted by Support - May 10, 2011
Website
Server Side Filtering will be implemented for TADTable. We will consider to implement that for TADQuery.

5/9. Just TADTable?
Posted by RReyes - May 10, 2011
Website
Hi. Sorry but I disagree with you that only implement this functionality in the TADTable component and that this functionality will be considered for future implementations in the TADQuery, when the main component to develop Client / Server applications is the TADQuery. The TADTable component, from my point of view, is just to maintain compatibility with the BDE. I hope you change your mind.

6/9. Not just
Posted by Support - May 11, 2011
Website

1) The "right" TADTable is important for BDE application migration.

2) TADTable generates SQL, including WHERE phrase. TADQuery requires to parse SQL. That is different work and it will be performed later.

3) You can: http://anydac.uservoice.com/forums/89337-general/suggestions/1528521-tadquery-and-server-side-filtering?ref=title


7/9. Good new, very good
Posted by Stefano Monterisi - May 11, 2011
Website

This is a great news. If it works really as I understand, I can have a grid that manage (at user level) one million of records that are fetched "on need", without manage the entire result set, but only few "chuncks" (mirate sql select)... Very very good. I have looked for this solution from 2000....:-) I am waiting ..

Please insert supporto for ElevateDb also!!!!

Good job!


8/9. Release date?
Posted by Stefano Monterisi - May 16, 2011
Website

Hi, I need this feature for migrate "BDE like" application, that have the capabilty to show the entire dataset in grids for order, search, etc... I hope this is a great feature, One question: There is a release date for a betas? I want to test it ....
Thanks in advance!

Stefano Monterisi


9/9. Soon
Posted by Support - May 16, 2011
Website
The AnyDAC v 5.0 beta will be released this week. The beta will be accessible to all our great customers with the active subscriptions. The beta will include new TADTable, new Advantage driver and more. Subscribe to da-soft news in your profile, so you will not miss the beta release.

Add Comments