Re: clist->append() 10000 rows from sqlite - how to speed it up
| From: | Brian A. Stumm | Date: | Fri, 03 Nov 2006 17:29:26 +0000 |
| Subject: | Re: clist->append() 10000 rows from sqlite - how to speed it up | ||
| References: | 1 | Groups: | php.gtk.general |
| Request: | Send a blank email to php-gtk-general+get-7439@lists.php.net to get a copy of this message | ||
Try paginating the results...
$result = sqlite_query( $db, "SELECT * FROM Enterprises limit " .
$startrow . ", 25" );
then use a count(*) query to determine total rows, divided by results per
page to offer links for next, prev pages etc...
On Fri, 3 Nov 2006 q11@gala.net wrote:
>
> Hello!
> I`m writing a database viewer with searching abilieties, based on SQLite
> engine, under win2k, DB itself isn`t big - approx 10000 rows.
>
> Here is code sample:
>
> function getdata(){
> global $list, $db;
> $list -> freeze();
> sqlite_query( $db, "BEGIN TRANSACTION" );
> $result = sqlite_query( $db, "SELECT * FROM Enterprises" );
> while( $row = sqlite_fetch_array($result) ){
> while( gtk::events_pending() ) gtk::main_iteration();
> $list -> append( array( $row['n'], $row['Code'],
> $row['Name'],
> $row['Phone'], $row['Region'], $row['Town'],
> $row['Street'], $row['House'],
> $row['Office'], $row['Email'] ) );
> }
> sqlite_query( $db, "COMMIT" );
> $list -> thaw();
> }
>
> This loop takes about 2 seconds to fill GtkCList, I think it`s kinda slow.
> The reason I`m asking is that: if user wishes to find all enterprises having
> "a" letter in the Name, my program should make this query
> "SELECT * FROM Enterprises WHERE Name LIKE '%a%'"
> and again, lots of $list->append(...) will be execuded slowly.
>
> Is there a way to speed up appending?
> May be some tricks exist?
>
> P.S. þÕÔØ ÎÅ ÚÁÂÙÌ, ÔÕÔ ÉÎÔÅÒÅÓÎÁÑ ×ÁËÁÎÓÉÑ ÄÌÑ ÔÅÂÑ:
> http://www.rabota.com.ua/?ito=1017
> ____________________________________________________________
>
> âÅÓÐÌÁÔÎÁÑ ÐÏÞÔÏ×ÁÑ ÓÌÕÖÂÁ Gala Mail -
> http://mail.gala.net/
> WEB, WAP É POP3 ÄÏÓÔÕÐ, ÍÏÝÎÙÅ ÆÉÌØÔÒÙ É ÚÁÝÉÔÁ ÏÔ ÓÐÁÍÁ.
>
>
--
a8888b.
Brian A. Stumm d888888b.
bs@bs-linux.com 8P"YP"Y88
http://www.bs-linux.com
8|o||o|88
The Choice of a Gnu Generation 8' .88
8`._.' Y8.
# d/ `8b.
#### ### .dP . Y8b.
## # d8:' " `::88b.
## ### ### ### ### ### ### ### d8" `Y88b
## # ## ### ## ## ## ## ## :8P ' :888
## # ## ## ## ## ## ### 8a. : _a88P
## ### ## ## ## ## ### ._/"Yaa_ : .| 88P|
## # ### ## ## ## ## ## ## \ YP"
| 8P .
## ## ### # ## ## ### ### ## ## / \._____.d| .'
######### ### #### #### ### ### ### ### --..__)888888P._.'