08 February 2011

NEVER use Count with SQLite

Let be honest, Flex on Android isn't synonym with "Speed"
Even with a paged array (I won 10sec with it), I was fighting for 2hours with a 15 sec(!) delay before filling a list.

FYI, I'm using a 3000 rows table and id is a key...

If i use
(sql) SELECT COUNT(id) as count FROM mytable
and
(as3) return stmt.getResult().data[0]["count"];
this tooks 15 sec...

If I use
(sql) SELECT id FROM mytable
and
(as3) return stmt.getResult().data.lenght
this tooks 0.4 sec

so NEVER use COUNT!
Google it, you'll find COUNT isn't optimized at all on SQLite

1 comment:

Marty Pitt said...

Wow. That's shocking! Thanks for sharing.