Subject Re: [firebird-support] what actually does the index statistics work
Author Helen Borrie
At 02:09 AM 27/01/2007, you wrote:
>If I use the SP below to rebuild all index statistics which process
>actually does the work. I could see that it could be either the
>process that runs the SP (which is what I actually want) or it could
>be the next process to try and use an index (similiar to GC), or its
>probably something else I haven't thought of.

It recalculates the selectivity of the index and writes the result to
RDB$INDICES (and RDB$INDEX_SEGMENTS in v.2.x). To ensure that cached
index pages are not contaminated by the changes, the in-memory
selectivity graph is built at the time the database file is opened by
the server. The effect won't be felt by the current process, but
next time the database file is opened. This means different things
depending on the server model:

-- Superserver, next time the database has been shut down and
restarted (or all connections have been closed and one user logs in)

-- Classic, all subsequent connections

-- embedded (both SS and Classic) next time the application is started and
connects to the database

Note also that SET STATISTICS doesn't rebuild indexes; and it won't
work if the user running it is neither SYSDBA nor the owner of the table.

No doubt Ann or Arno will add some enlightenment to this....

./hb