firebird icon indicating copy to clipboard operation
firebird copied to clipboard

[FR] alter index active must make every effort on unique/primary key index with dup values

Open basid-irk opened this issue 3 years ago • 8 comments

Sometimes (in unclear cases) dup values may appear in unique/primary key index. Now alter index active DDL are stop on first problematic record and and show only one report. alter index active must make every effort on unique/primary key index with dup values and show them all. With dbkey (sub)list for each problematic record, if possible.

basid-irk avatar Aug 18 '22 10:08 basid-irk

Why not running query to find duplicates? SELECT ID+0 FROM MY_TABLE GROUP BY ID+0 HAVING COUNT(*)>1

livius2 avatar Aug 24 '22 09:08 livius2

I see no value in such feature. More, it is not clear how to report thousands of duplicates via status-vector and why it is needed at all in general use case. If one need to know complete list of duplicates, he could query table as @livius2 shows above.

hvlad avatar Aug 24 '22 10:08 hvlad

On 8/24/22 13:40, Vlad Khorsun wrote:

I see no value in such feature. More, it is not clear how to report thousands of duplicates via status-vector

Since FB4 theoretically possible, but IMHO that (if ever implemented) should go into log file or stdout (like verbose output). There is even no conflict with transfer of backup to client even when gbak runs as service cause it's all @ restore time.

and why it is needed at all in general use case. If one need to know complete list of duplicates, he could query table as @livius2 https://github.com/livius2 shows above.

Definitely. Useless feature. Just waste of time in gbak after error anyway happened.

AlexPeshkoff avatar Aug 24 '22 11:08 AlexPeshkoff

Indices could be built not only by gbak ;)

hvlad avatar Aug 24 '22 11:08 hvlad

Engine may write info about all dup's in firebird.log and save in status vector only two counter - total problematics records and count of problematics group (dup's itself).

basid-irk avatar Aug 29 '22 13:08 basid-irk

@basid-irk but why do you need such info if you can query database to see it?

livius2 avatar Aug 29 '22 16:08 livius2

If possible save full info about all problems - do it. Current case not required excessive CPU/IO load. If unique index fully built, but definitely contain duplicates - such index still prevent new duplicates and, may be, can be used in queries.

basid-irk avatar Aug 30 '22 01:08 basid-irk

I do suppose that crating invalid index is no go in database world. And about CPU/IO, index creation is no magic, during creation engine must scan whole data pages for values and sort them. It is "the same" what is done by above query.

livius2 avatar Aug 30 '22 05:08 livius2

On fully index (re)build all dups should logged in firebird.log and after should return (only) last error. Other aspects may retain as currently - only return last (not first) error.

basid-irk avatar Mar 21 '23 04:03 basid-irk