mercredi 29 avril 2015

query efficiency for boolean record

I have some tables with boolean column, e.g. an active column to indicate whether a user is active or now, then to query all inactive user I use

select * from users where active = 0

But I suspect the query will be slow when user records become huge. I am considering adding another table to record those inactive users (just record their primary key or their rowid).

One problem with that is I have other table with boolean column, say a processed column to record whether an orders has been processed or not and query all unprocessed orders with

select * from orders where processed = 0

So I may need to add another table for order or just use one table to record all "false" records. Any performance tips for query boolean records? I use sqlite but I assume other database will have the problem as well.

Aucun commentaire:

Enregistrer un commentaire