Issue 12747 - re-fetch of every row in a DB-Table
Summary: re-fetch of every row in a DB-Table
Status: CLOSED FIXED
Alias: None
Product: Base
Classification: Application
Component: code (show other issues)
Version: OOo 1.1 Beta
Hardware: PC Windows 2000
: P1 (highest) Trivial (vote)
Target Milestone: OOo 1.1 Beta2
Assignee: ocke.janssen
QA Contact: issues@dba
URL:
Keywords:
: 12748 (view as issue list)
Depends on:
Blocks:
 
Reported: 2003-03-27 19:36 UTC by hermann
Modified: 2006-05-31 14:29 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description hermann 2003-03-27 19:36:04 UTC
Hi Frank,*,
I have made some tracing with hsqldb, so their are some strange things:

if I select a table in the DB-Explorer, OOo does first a:
select <ColumnName> from <Tablename> where 0=1 , and this for every Column
and than for every row of the resultset a:
SELECT * FROM "OOTable1" WHERE "OOTable1"."OOID" = 9

where 9 is only a single primaryKey. For me it seems that OOo builds the
resultsets by iterate thru this by singele sql-statements. 
If I go with basic to the db, all works fine.

BTW:
If anybody is looking as this, perhaps someone can point me to the steps what
OOo does by clicking on a table in the db-explorer
Comment 1 Frank Schönheit 2003-03-28 06:47:29 UTC
*** Issue 12748 has been marked as a duplicate of this issue. ***
Comment 2 Frank Schönheit 2003-03-31 08:40:36 UTC
confirming at least the first part, which is calling a "SELECT
<column> FROM <table> WHERE 0 = 1" for every column.

For the second part: I am not yet clear about this, normally, I'd
expect that there is only one statement/result set needed for
retrieving all the data.

Ocke, can you please investigate both parts? For the first, I think we
should see if we can reduce the number of statements - if they're all
triggered from the same place (the query composer), the we (try to)
should optimize this place.
For the second, I think we should first investigate what's causing
this ...
Thanks :)
Comment 3 hermann 2003-04-07 14:58:27 UTC
Hi Ocke,
I found out, that with SAPDB the refetch of every row not happens. So
I wondered and looked around in the Metadata. With Basic I have a
Property FetchSize in the ResultSet-Object of OOo. In Mysql this is 0,
in hsqldb 1 and in sapdb 30000. Perhaps this could be a reason.
But I dont find out where OOo has this info from. Do you know this?
Because than I could change the driver :-)
Comment 4 ocke.janssen 2003-04-08 07:05:32 UTC
Hi Hermann,

what does you baisc marco do? If it creates a RowSet the fetchsize
defines the size of the cache which holds the row currently fetched. 1
means that only one row will be hold, could be used when only updates
and new rows are going to be inserted otherwise I would prefer 50. The
data source browser use the size of the window and calculates it's
size automaticly. But I don't know where this 30000 from SAPDB comes from.


Best regards,

Ocke
Comment 5 hermann 2003-04-08 09:26:15 UTC
my Basic Macro creates only a com.sun.star.sdb.DatabaseContext and
loops thru the registered Databases. Then I get a Connection and
create a statement. After doing a: Select * from <Tablename> I got a
com.sun.star.sdb.OResultSet back and this Resultset has some
Properties including fetchSize. 
I dont change them and I dont know where the values come from.

BTW: with this Basic-Script the refetch does not happen. This is only
if I go with the DataSource Browser. I thought this could be a
starting-Point to look for
Comment 6 ocke.janssen 2003-04-09 10:51:12 UTC
I reduced the calls for "select name from 0=1" to a call like "select
* from 0=1", so this should be fixed in the next version.

The FetchSize is initial set by the driver itself. You may have a look
at the ResultSet method "getFetchSize". HSQLDB returns always 1.

What we do in the RowSet is to fetch every row with their primary key.
So we have a cache which holds only the primary key and when the data
is needed we use it to fetch the whole row. When you set the FetchSize
for the RowSet, it should hold excatly FetchSize rows and for the
other it holds only the primary key.

Best regards,

Ocke

PS: I set this one to fixed. If there exists still a bug with the
FetchSize please submit a new issue, Thx.
Comment 7 ocke.janssen 2003-04-09 12:02:05 UTC
Changed target.
Comment 8 hermann 2003-04-09 19:04:01 UTC
Hi Ocke,

I can switch the Fetchsize to whatever I will, OOo creates a
select-Statement for every row in the Table. And if I understand you
right, than OOo fetch every row with primary key again. Why does OOo
not use the resultset from select * ...
What is if I have a Table with 30000 rows over network? is this
performant and necessary?
What is anout MySQL? it gives 0 as FetchSize back. And as Frank told,
another User have the Problem that OOo is very very slow with great
Tables. 
Comment 9 ocke.janssen 2003-04-10 11:40:21 UTC
First of all be have to decide between the RowSet and a normal
ResultSet directly created from the Statement. The FetchSize of the
ResultSet depends on the driver and depends on the preson developed
it. The FetchSize for the RowSet only defines the size of rows which
will be currently cached. When it is set to 50 then only 50 rows will
be in memory. So the RowSet will "only" call 50 times the prepared
statement. If the cache (window) moves to the 51 row it will use the
ResultSet of the statement to fetch the primary key for the 51 row and
then fetch the row with all columns. 

The problem with the very very slow tables was a problem that a select
statement 0=1 was sent to the database for every column in the table,
but this is fixed.
Comment 10 hermann 2003-04-10 17:34:53 UTC
Hi Ocke,

now I see that this is true and 'only' for the rowset every row is
fetched again. But now when I work with great tables, I see in the
Database Browser not the available Rows, only the number of rows that
are in cache. And scrolling works very slow too. 
But If this is right so, I changed back to fixed (hope it works).
Comment 11 ocke.janssen 2003-04-17 15:07:46 UTC
Please verify.
Comment 12 marc.neumann 2003-04-22 12:08:04 UTC
What ?
Comment 13 ocke.janssen 2003-04-22 13:16:39 UTC
For example enable tracing for ODBC and count how often the call
SQLColumns is called when selecting one table in the beamer. Should
around 3-4 times.

BEst regards,

Ocke
Comment 14 marc.neumann 2003-04-22 13:46:55 UTC
Hi,

I found the call SQLColumn 4 times in the log file when open a ODBC
table on a MS SQl Server.
So the bug is fixed.

Bye Marc

Comment 15 marc.neumann 2003-04-22 13:47:32 UTC
verified in internal development build
Comment 16 ocke.janssen 2003-06-17 07:52:42 UTC
Closing now.
Comment 17 hans_werner67 2004-02-02 12:57:44 UTC
change subcomponent to 'none'