Subject | Re: [firebird-support] Re: ORDER BY on large VARCHAR columns |
---|---|
Author | Helen Borrie |
Post date | 2004-10-27T15:28:57Z |
At 01:43 AM 27/10/2004 +0000, you wrote:
create table blah (
id integer not null primary key,
....
drive varchar(50),
level1 varchar(50),
level2 varchar(50),
level3 varchar(50),
level4 varchar(820),
Full_path varchar(1024));
create trigger ba_blah for blah
active before insert or update
as
declare NeedToNull char = 'T';
begin
if (new.drive is not null) then
begin
new.Full_path = new.drive;
NeedToNull := 'F';
end
if (new.level1 is not null) then
begin
if (NeedToNull = 'T') then
begin
new.Full_path = new.level1;
NeedToNull = 'F';
end
else
new.Full_path = new.Full_path || '\' || new.level1;
if (new.level2 is not null) then
begin
if (NeedToNull = 'T') then
begin
new.Full_path = new.level2;
NeedToNull = 'F';
end
else
new.Full_path = new.Full_path || '\' || new.level2;
if (new.level3 is not null) then
begin
if (NeedToNull = 'T') then
begin
new.Full_path = new.level3;
NeedToNull = 'F';
end
else
new.Full_path = new.Full_path || '\' || new.level3;
if (new.level4 is not null) then
begin
if (NeedToNull = 'T') then
begin
new.Full_path = new.level4;
NeedToNull = 'F';
end
else
new.Full_path = new.Full_path || '\' || new.level4;
if (NeedToNull = 'T') then
new.Full_path = null;
end
the last (the one that potentially contains the big string).
less, in some cases a LOT less. Also, multi-segment indexes eat even more
out of those 253 bytes.
./hb
><unordained_00@c...> wrote:Ach!! Let's take a Windows file path as an example.
> > ... they can't be chopped up -and- indexing just the first 250 or
>so chars wouldn't at least help
> > somewhat? in theory it would reduce by orders of magnitude how
>many comparisons would be needed,
> > even if the index couldn't do the entire sort by itself ... or,
>heck, four or five varchar fields,
> > using substring? doesn't need to be hierarchical, you've got a set
>limit on the length ...
> >
>
>Well, I have a UDF to perform regex searches on this column, so I
>can't really split them up as I have no idea where the wildcards may
>be in the search pattern. It's just a very problematic field.
create table blah (
id integer not null primary key,
....
drive varchar(50),
level1 varchar(50),
level2 varchar(50),
level3 varchar(50),
level4 varchar(820),
Full_path varchar(1024));
create trigger ba_blah for blah
active before insert or update
as
declare NeedToNull char = 'T';
begin
if (new.drive is not null) then
begin
new.Full_path = new.drive;
NeedToNull := 'F';
end
if (new.level1 is not null) then
begin
if (NeedToNull = 'T') then
begin
new.Full_path = new.level1;
NeedToNull = 'F';
end
else
new.Full_path = new.Full_path || '\' || new.level1;
if (new.level2 is not null) then
begin
if (NeedToNull = 'T') then
begin
new.Full_path = new.level2;
NeedToNull = 'F';
end
else
new.Full_path = new.Full_path || '\' || new.level2;
if (new.level3 is not null) then
begin
if (NeedToNull = 'T') then
begin
new.Full_path = new.level3;
NeedToNull = 'F';
end
else
new.Full_path = new.Full_path || '\' || new.level3;
if (new.level4 is not null) then
begin
if (NeedToNull = 'T') then
begin
new.Full_path = new.level4;
NeedToNull = 'F';
end
else
new.Full_path = new.Full_path || '\' || new.level4;
if (NeedToNull = 'T') then
new.Full_path = null;
end
>Also, there is a requirement that they be displayed -- fullyNP. If they are broken apart, you can put an index on each level except
>qualified, sorted, and paged (i.e. 15-20 at a time).
the last (the one that potentially contains the big string).
>Can Firebird use a partial (i.e. substring) INDEX and have thatAn index can't be larger than 253 bytes. In many character sets it is
>index help it sort this table? I didn't think so, but maybe I'm not
>sure what you mean by "indexing just the first 250 or so chars".
less, in some cases a LOT less. Also, multi-segment indexes eat even more
out of those 253 bytes.
./hb