Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 1BEAB475D84 for ; Sat, 19 Oct 2002 03:33:44 -0400 (EDT) Received: from corporate.fx.ro (corporate.fx.ro [193.231.208.29]) by postgresql.org (Postfix) with ESMTP id 8C1D4475CCE for ; Sat, 19 Oct 2002 03:33:42 -0400 (EDT) Received: from fx.ro (Beavis.fx.ro [193.231.208.21]) by corporate.fx.ro (8.10.1/8.10.1) with ESMTP id g9J7Xjd29280 for ; Sat, 19 Oct 2002 10:33:45 +0300 Received: from coto (ppp12149.fx.ro [195.7.1.149]) by fx.ro (8.10.1/8.10.1) with ESMTP id g9J7Xcp20719 for ; Sat, 19 Oct 2002 10:33:40 +0300 (EET DST) Received: by coto (Postfix, from userid 1000) id 4F1C815221; Sat, 19 Oct 2002 13:23:52 +0300 (EEST) Date: Sat, 19 Oct 2002 13:23:52 +0300 From: am@fx.ro To: pgsql-interfaces@postgresql.org Subject: Handling data in libpq Message-ID: <20021019132352.A419@coto> References: <80bf0666.0210170015.59e12eed@posting.google.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <80bf0666.0210170015.59e12eed@posting.google.com>; from dkovt@ems-hitech.com on Thu, Oct 17, 2002 at 01:15:30AM -0700 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200210/61 X-Sequence-Number: 3223 Hello everyone! I have written a C program that: - displays in a tabular form the data in a table - allows inserts,deletes,updates, and user-defined filters('enter a query') - uses libpq and ncurses. The program is rather inefficient right now : - In order to fetch the data, i call: RecordSet = PQexec(conn,"select FIELD1,...,FIELDn,OID from TBL"); nRecords = PQntuples(RecordSet); - when i need a specific tuple, i call : PQgetvalue(RecordSet,crtRecord,field); for each field I'm looking for a new approach regarding fetching the data. Usage of cursors is probably the path to follow. I would be deeply grateful to anyone who would share a bit of his/her experience: - i assume the table has 50000 tuples - what is better: to fetch one tuple at one time, or to fetch a certain number of tuples (let's say 100). - if i fetch 100 tuples, PQntuples returns 100? how do i know how many rows has the table? - i have the impression that keeping track of the tuple's index i nside the RecordSet and the index inside the whole table is quite tricky, but manageable. How do you guys handle this kind of situations? - are there more examples that use cursors, except the ones in docs ( in the libpq chapter )? Thanks, Adrian Maier (am@fx.ro)