Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SET STATISTICS ALL, REBUILD INDEX INDEX_NAME and REBUILD INDEXES [CORE1580] #1999

Open
firebird-automations opened this issue Nov 9, 2007 · 14 comments

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: @livius2

Votes: 4

Add posibility to update statistics for all indexes in one comand like:

Set Statistixs ALL;

and Add posibility to rebuild index (also system) like:

REBUILD INDEX INDEX_NAME;

and the same as above rebuild all

REBUILD INDEX ALL;

@firebird-automations
Copy link
Collaborator Author

Commented by: @AlexPeshkoff

Rebuild of index is done using
alter index <name> inactive
alter index <name> active

In order to do it (or set statistics) for all indices is easily done in stored procedure, using select from rdb$indices and execute statement.

Taking it into an account, changed the priority.

@firebird-automations
Copy link
Collaborator Author

Modified by: @AlexPeshkoff

priority: Major [ 3 ] => Minor [ 4 ]

@firebird-automations
Copy link
Collaborator Author

Commented by: @livius2

>> Rebuild of index is done using
>> alter index <name> inactive
>> alter index <name> active

yes but :

1. we can not inactive system indexes
2. this are two comands but should be one
3. this can do some malfunction (degradate performance) if user run some query when index is inactive

this is good :)
In order to do it (or set statistics) for all indices is easily done in stored procedure, using select from rdb$indices and execute statement.

but can be included in SET STATISTIC statement
this could be more intuitive to use

@firebird-automations
Copy link
Collaborator Author

Commented by: @pcisar

Except rebuild of system indices, this really could be easily done in stored procedure. But this is not single case when useful "higher level" actions could be performed or interesting information could be gathered from system tables using SP's or Views. I think that we could provide such useful extensions as build-in database metadata (another layer on top of system tables considered as standard part of the database) or at least as standard enhancement scripts that could be executed on new database to enhance it's capabilities.

@firebird-automations
Copy link
Collaborator Author

Commented by: Smirnoff Serg (wildsery)

> I think that we could provide such useful extensions as build-in database metadata (another layer on top of system tables considered as standard part of the database) or at least as standard enhancement scripts...

Maybe some execute blocks in \examples\execute_blocks\ will be sufficient?

@firebird-automations
Copy link
Collaborator Author

Commented by: @dyemanov

Why would you need to rebuild the indices at all?

@firebird-automations
Copy link
Collaborator Author

Commented by: @pcisar

To make them dense (use index pages in full) again after mass update ?

@firebird-automations
Copy link
Collaborator Author

Commented by: @cincuranet

AFAIK if you need to rebuild index "structure" you don't need to inactive it. Just calling active is good. So it works for PK too.

@firebird-automations
Copy link
Collaborator Author

Modified by: @pcisar

Workflow: jira [ 13395 ] => Firebird [ 14007 ]

@firebird-automations
Copy link
Collaborator Author

Commented by: @livius2

>>Jiri Cincura - [13/Nov/07 04:31 PM ]
>>AFAIK if you need to rebuild index "structure" you don't need to inactive it. Just calling active is good. So it >>works for PK too.

can this be used on working database (when users are connected)
or this can corrupt database?

@firebird-automations
Copy link
Collaborator Author

Commented by: @cincuranet

Yes, you can use it on active database.

@firebird-automations
Copy link
Collaborator Author

Commented by: @livius2

Really? - what with FireBird 1.5

I do this on working database
and now i can not create any new procedure
i get error something like "index was deleted ..."

@firebird-automations
Copy link
Collaborator Author

Commented by: Diogo Andre Loff (dloff)

como baixa

@firebird-automations
Copy link
Collaborator Author

Commented by: @luronumen

You can recalculate statistics for all indexes using this simple SQL statement:

SET TERM ^ ;
EXECUTE BLOCK
AS
DECLARE INDEX_NAME VARCHAR(31);
BEGIN
FOR SELECT RDB$INDEX_NAME FROM RDB$INDICES INTO :INDEX_NAME DO
EXECUTE STATEMENT 'SET STATISTICS INDEX ' || :INDEX_NAME || ';';
END^
SET TERM ; ^
COMMIT;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant