Subject | Re: Max key size? |
---|---|
Author | Adam |
Post date | 2006-02-24T11:19:08Z |
--- In firebird-support@yahoogroups.com, Kjell Rilbe <kjell.rilbe@...>
wrote:
You don't tell us which of these fields is int and which is varchar,
but guessing at the obvious (Info varchar(200), Code Integer).
other field in a superkey.
uniqueness. Judging from the selectivity of Detail(Code, ID) below,
you have duplicates and lots of them. Unless you mean that it should
be an ascending index??
Unless I am reading your selectivity wrong, shouldn't it be around 0.2
if this was the case? It is I suppose possible your statistics are way
out of date. Run set statistics to see if it changes.
Adam
wrote:
>I believe it is around 252 bytes. Is this a multi-byte charset?
> Please remind me, what is the max key size in FIrebird 1.5?
>
> I just failed to create a compound index on these two columns:
> - int
> - varchar(200)
>possible:
> What I actually need is to make the following queries as fast as
You don't tell us which of these fields is int and which is varchar,
but guessing at the obvious (Info varchar(200), Code Integer).
>You will want an index either on Code or on Code combined with some
> UPDATE "Master"
> SET "Info" = :Caption
> WHERE "Code" = :Code;
other field in a superkey.
> UPDATE "Master" Mthat it
> SET "Info" = "Info" || '; ' || :Caption
> WHERE EXISTS (
> SELECT 1
> FROM "Detail" D
> WHERE D."Id" = M."Id"
> AND D."Code" = :Code
> )
> AND M."Info" IS NOT NULL;
>
> UPDATE "Master" M
> SET "Info" = :Caption
> WHERE EXISTS (
> SELECT 1
> FROM "Detail" D
> WHERE D."Id" = M."Id"
> AND D."Code" = :Code
> )
> AND M."Info" IS NULL;
>
> "Master" ("Id") is primary key.
>
> "Detail" ("Id", "Code") should be primary key but I just noticed
> isn't.Hmmm, that wont work. Code/Detail is the same as Detail/Code in
uniqueness. Judging from the selectivity of Detail(Code, ID) below,
you have duplicates and lots of them. Unless you mean that it should
be an ascending index??
>IIRC, statistics is pretty much = (distinct values / total values)
> "Detail" ("Code", "Id") has a non-unique ascending index (selectivity
> 0.002433).
>
> "Detail" contains up to about five record for each "Master".
Unless I am reading your selectivity wrong, shouldn't it be around 0.2
if this was the case? It is I suppose possible your statistics are way
out of date. Run set statistics to see if it changes.
Adam