On 30-Dec-08, at 7:29 PM, João Henrique Freitas wrote: > Hello, > > To solve it quickly I will use 'select count.....'. Later I will think > in other way to solve this. Maybe a way to do libdbi work without know > how many rows.
As Markus says, 'streaming' access to a result set has been mentioned here before. I believe it is on Markus' wish list. In short, because the existing API requires random access to the result set, libdbi must always fetch the whole thing. This constrains the practical size of result sets and is unnecessary memory pressure for libdbi clients which simply use results sequentially. Probably most of the drivers can be used more efficiently with such an alternative API. Not knowing the row count can be worked around. See the code in the Ingres driver for one method (allocate an initial block, then re- alloc in (increasing) increments each time it fills up). --Toby > > Thanks. > > On Tue, Dec 30, 2008 at 8:42 PM, Markus Hoenicka > <markus.hoeni...@mhoenicka.de> wrote: >> Hi, >> >> I recall a similar discussion lately, although I couldn't find any >> trace of it in the archives (I found a copy here though: >> http://www.mail-archive.com/libdbi-drivers- >> de...@lists.sourceforge.net/msg00276.html). Unless >> we implement the alternative interface suggested in that discussion, >> running 'select count(*) from ([big select here])' is probably your >> only chance to squeeze the DB2 driver into the libdbi framework. It >> clearly shows that libdbi was not designed with Oracle or DB2 in >> mind. >> >> regards, >> Markus >> >> >> João Henrique Freitas writes: >>> Hello, >>> >>> I started to develop a IBM DB2 driver to libdbi (about 70% was done) >>> >>> Currently the libdbi need know about how many rows a select query >>> need >>> to return then allocate the rows need. The DB2 API don't have any >>> function to return the number of rows. >>> >>> How I can do it? >>> >>> One way to solve this is perform the query: 'select count(*) from >>> ([big select here])' before send the 'big select' query . This can >>> tell me how many rows the select return. >>> >>> I think DB2 and Oracle have this 'problem'. These database engines >>> works with result set and row set. But libdbi need to know the total >>> rows return to allocate the memory need. >>> >>> Thanks. >>> >>> -- >>> ----------------------------------------------------------- >>> João Henrique Freitas - joaohf_at_gmail.com >>> Campinas-SP-Brasil >>> BSD051283 >>> LPI 1 >>> http://www.joaohfreitas.eti.br >>> -------------------------------------------------------------------- >>> ---------- >>> _______________________________________________ >>> Libdbi-drivers-devel mailing list >>> Libdbi-drivers-devel@lists.sourceforge.net >>> https://lists.sourceforge.net/lists/listinfo/libdbi-drivers-devel >> >> -- >> Markus Hoenicka >> markus.hoeni...@cats.de >> (Spam-protected email: replace the quadrupeds with "mhoenicka") >> http://www.mhoenicka.de >> > > > > -- > ----------------------------------------------------------- > João Henrique Freitas - joaohf_at_gmail.com > Campinas-SP-Brasil > BSD051283 > LPI 1 > http://www.joaohfreitas.eti.br > ---------------------------------------------------------------------- > -------- > _______________________________________________ > Libdbi-drivers-devel mailing list > Libdbi-drivers-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/libdbi-drivers-devel ------------------------------------------------------------------------------ _______________________________________________ Libdbi-drivers-devel mailing list Libdbi-drivers-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libdbi-drivers-devel