Subject RE: [IBO] General performance questions
Author Thomas Steinmaurer
Hello Helen,

[snip]

> >During the creation of the hierarchical treeview, I have to check
> >for each column and the corresponding operation whether a record
> >in the above table exists or not.
> >
> >What's the best way to do that regarding speed, network traffic
> >and memory consumption on the client (the result set of the above
> >table can be pretty huge)?
> >
> >Probably there are different possibilities available:
> >
> >1) Using a parametrized query and executing each time something
> >like:
> >
> >SELECT COUNT(*) AS COLUMN_EXISTS FROM METATABLE
> >WHERE TABLE_NAME = ? AND OPERATION = ? AND COLUMN_NAME = ?
> >
> >2) Using a buffered TIB_Query and fetch all records from the
> >above table to the client und use a Locate() to check the existance
> >of a record
> >
> >3) Or any other IBO smarties I'm not aware of ;-)
> >
> >Any comments/hints appreciated.
>
> Combine an "SQL smartie" with an "IBO smartie":
>
> SELECT 1 AS COLUMN_EXISTS FROM RDB$DATABASE
> WHERE (EXISTS
> (SELECT 1 FROM METATABLE
> WHERE TABLE_NAME = ? AND OPERATION = ? AND COLUMN_NAME = ?))
>
> This will return error 335544374 if no record exists, so this is where you
> can capitalise on IBO's OnError event and have a fast, low-memory way to
> test for existence.

Smart, but for my case not smart enough ;-). Would your proposed
solution really differ from 1) ?

I have a remote test database on a 10 MBit LAN for test purposes
(Luc is providing me with huge databases periodically ;-)), with
3429 columns. This would mean that either 1) or your statement
is executed 10287 times (3429 * 3 = 10287) over the network.
=> Pretty slow (2:10 minutes for analyzing the entire database).

ad 2): This is significantly faster (40 sec. including fetching all
rows (10287) from the server).

To reduce a fetch all I should probably fetch only all records from
the METATABLE for a *given* table, using Locate() than to check the
existance and proceed with the next table ...

Thank you,
Thomas