Subject Re: [firebird-support] How to optimize queries on field state
Author Germán Balbi
The idea is the following.
Have products and services that pass through different states (order, committed, reviewed, approved, slope, bill, invoice), these may belong to a period or many (period = months).
The filter may include the client query or not.

La idea es la siguiente.
Tengo productos y servicio que pasan por distintos estados (pedido, comprometido,revisado, aprovado, pendiente, a facturar, facturado), estos pueden pertenecer a un periodo o a muchos (periodo=meses).
El filtro del query puede incluir el cliente o no.



El Miércoles, 3 de febrero, 2016 12:23:31, "Thomas Steinmaurer ts@... [firebird-support]" <firebird-support@yahoogroups.com> escribió:


 
> I have a state machine (workflow) implemented on a table a couple of
> million records and growing.
> I have crated an index on the "state" field. The possible states are
> very few (5 to 10). Obviously selectivity index is terrible. As I can
> optimize the query?

Hard to say without seeing an actual query ...

Is the state field the only one used to filter the result set?

--
With regards,
Thomas Steinmaurer
http://www.upscene.com/

Professional Tools and Services for Firebird
FB TraceManager, IB LogManager, Database Health Check, Tuning etc.