On 9/22/08, Zbigniew Baniewski <[EMAIL PROTECTED]> wrote:
> On Mon, Sep 22, 2008 at 12:17:44PM +1000, BareFeet wrote:
>
>  > select exists (select 1 from MyTable where condition)
>  >
>  > which will return a boolean result, and stop scanning the table after
>  > the first match is found.
>
>
> Yes, thanks - that's right: it is partial solution indeed. "Partial" -
>  because in the case of non-existence it has to scan the table to the end
>  anyway.
>
>  But still it's better than "count(*)".

The bottom line is -- when using conditions, (WHERE constraints),
indexes will (should) speed up your queries except when using LIKE
constraints. In which case, looping through your result and counting
the results will be fast. When not using condition, indexes don't help
anyway, and count(*) involves a full table scan. If you don't want to
do that, maintain a separate table with the count of rows for every
table.


>  --
>                                 pozdrawiam / regards
>
>
>                                                 Zbigniew Baniewski
>
> _______________________________________________
>  sqlite-users mailing list
>  sqlite-users@sqlite.org
>  http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>


-- 
Puneet Kishor http://punkish.eidesis.org/
Nelson Institute for Environmental Studies http://www.nelson.wisc.edu/
Open Source Geospatial Foundation (OSGeo) http://www.osgeo.org/
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to