I submitted this question some time ago, but now the problem is very serious.
I was using in freebsd 8 and 9 firebird server 2.5.1. It was configured so that every night I used gbak to save the database and then gbak -r to restore it to remove all limbo transactions and garbage and to optimize the database. Recently I upgraded firebird to firebird25-server-2.5.2_5 that is the last available for freebsd. After this upgrade everything is not working as first. Some queries require 80 times the time than before.
So I have tried to repeat the same query on the database not restored. The behaviour was as before. So I tried on other machines in linux (ubuntu) and on windows but the result was always the same. So I have tried to transfer all the data from the restored database to the one created by the previous version and also in this case the behaviour is good. So I have tried to delete and remake all the indices on the restored database, run gfix -sweep, gfix -validate full, but the result is always the same. So I think that there is something wrong in gbak when it creates the database from scratch. I don't know if the problem is the same when I create a new database, but now I have to use the old database and, if I need to restore an old version, I have to transfer all the records from the restored version to the good database. Both the databases are in the format:
"ISQL Version: FB-V184.108.40.206540 Firebird 2.5
Firebird/FreeBSD/amd64 (access method), version "FB-V220.127.116.11540 Firebird 2.5"
on disk structure version 11.2"
so the question in not related on the disk structure. Further the same thin happens on linux (ubuntu 3.13) an on windows 7 with Firebird 2.5.3.