Subject | Re: [firebird-support] Re: how much faster does a "real server" do? |
---|---|
Author | Helen Borrie |
Post date | 2006-05-28T14:19:34Z |
At 10:02 PM 28/05/2006, you wrote:
partitioning, at least avoid SELECT FIRST n SKIP .etc and use a cursor instead:
CREATE PROCEDURE GET_NEXT_20_DICENTRIES_BY_ID(
IDINPUT BIGINT)
RETURNS (
DATUM DATE,
AUTOR VARCHAR(31),
ZSQUELLE VARCHAR(15),
ZSDEF BLOB SUB_TYPE 1 SEGMENT SIZE 4096,
ASQUELLE VARCHAR(15),
ZSSEM VARCHAR(80),
UPDAUTOR VARCHAR(31),
ZSQCODE BIGINT,
ZSPRGM VARCHAR(20),
ASQCODE BIGINT,
ZSVERW VARCHAR(80),
ZSABK VARCHAR(10),
UPDDATUM DATE,
ZSAUDIO VARCHAR(20),
ASVERW VARCHAR(80),
ZSTERM VARCHAR(80),
ZSVIDEO VARCHAR(20),
ZSABBILDUNG VARCHAR(20),
ASVIDEO VARCHAR(20),
ASABBILDUNG VARCHAR(20),
PROJ VARCHAR(20),
ASDEF BLOB SUB_TYPE 1 SEGMENT SIZE 4096,
ASAUDIO VARCHAR(20),
REV VARCHAR(1),
ASSEM VARCHAR(80),
ASPRGM VARCHAR(20),
ASABK VARCHAR(10),
ASTERM VARCHAR(80),
ID BIGINT,
AUT BIGINT,
UPDAUT BIGINT)
AS
declare variable counter integer = 0;
begin
for
select d.id, d.asterm, d.asabk, d.asprgm, d.assem, d.zsterm,
d.zsabk, d.zsprgm, d.zssem, d.datum, d.proj, d.rev, d.upddatum,
d.asdef,
d.zsdef, d.asaudio, d.asvideo, d.asabbildung, d.zsabbildung,
d.zsaudio,
d.zsvideo, asmain.asterm, zsmain.zsterm, a.aut, ua.aut, aslit.qcode,
zslit.qcode, d.asqcode, d.zsqcode, d.aut, d.updaut
from dicentries d
left join dicentries asmain on d.asverw = asmain.id
left join dicentries zsmain on d.zsverw = zsmain.id
left join aut a on d.aut = a.id
left join aut ua on d.updaut = ua.id
left join lit aslit on d.asqcode = aslit.id
left join lit zslit on d.zsqcode = zslit.id
where d.id >= :idinput
/* order by d.id ascending */
into :id, :asterm, :asabk, :asprgm, :assem, :zsterm, :zsabk, :zsprgm,
:zssem, :datum, :proj, :rev, :upddatum, :asdef, :zsdef, :asaudio,
:asvideo,
:asabbildung, :zsabbildung, :zsaudio, :zsvideo, :asverw, :zsverw,
:autor,
:updautor, :asquelle, :zsquelle, :asqcode, :zsqcode, :aut, :updaut
do
begin
counter = counter + 1;
if (counter < 21) then
suspend;
else
exit;
end
./heLen
>--- In firebird-support@yahoogroups.com, Michael WeissenbacherYou're right, it's nothing like what you need. If you must do this
><mw@...> wrote:
> >
> > having looked over your post i have two questions:
> > - Why don't you use FIRST/SKIP syntax and instead submitting something
>
>I had never heard of skip before but I just googled it and it seems
>it's not useful for my purpose because something like "skip X" means
>"skip the first X records" but what i need is "those records whose id
>is smaller than X"; which are not necessarily (even probably) X
>records in numbers
partitioning, at least avoid SELECT FIRST n SKIP .etc and use a cursor instead:
CREATE PROCEDURE GET_NEXT_20_DICENTRIES_BY_ID(
IDINPUT BIGINT)
RETURNS (
DATUM DATE,
AUTOR VARCHAR(31),
ZSQUELLE VARCHAR(15),
ZSDEF BLOB SUB_TYPE 1 SEGMENT SIZE 4096,
ASQUELLE VARCHAR(15),
ZSSEM VARCHAR(80),
UPDAUTOR VARCHAR(31),
ZSQCODE BIGINT,
ZSPRGM VARCHAR(20),
ASQCODE BIGINT,
ZSVERW VARCHAR(80),
ZSABK VARCHAR(10),
UPDDATUM DATE,
ZSAUDIO VARCHAR(20),
ASVERW VARCHAR(80),
ZSTERM VARCHAR(80),
ZSVIDEO VARCHAR(20),
ZSABBILDUNG VARCHAR(20),
ASVIDEO VARCHAR(20),
ASABBILDUNG VARCHAR(20),
PROJ VARCHAR(20),
ASDEF BLOB SUB_TYPE 1 SEGMENT SIZE 4096,
ASAUDIO VARCHAR(20),
REV VARCHAR(1),
ASSEM VARCHAR(80),
ASPRGM VARCHAR(20),
ASABK VARCHAR(10),
ASTERM VARCHAR(80),
ID BIGINT,
AUT BIGINT,
UPDAUT BIGINT)
AS
declare variable counter integer = 0;
begin
for
select d.id, d.asterm, d.asabk, d.asprgm, d.assem, d.zsterm,
d.zsabk, d.zsprgm, d.zssem, d.datum, d.proj, d.rev, d.upddatum,
d.asdef,
d.zsdef, d.asaudio, d.asvideo, d.asabbildung, d.zsabbildung,
d.zsaudio,
d.zsvideo, asmain.asterm, zsmain.zsterm, a.aut, ua.aut, aslit.qcode,
zslit.qcode, d.asqcode, d.zsqcode, d.aut, d.updaut
from dicentries d
left join dicentries asmain on d.asverw = asmain.id
left join dicentries zsmain on d.zsverw = zsmain.id
left join aut a on d.aut = a.id
left join aut ua on d.updaut = ua.id
left join lit aslit on d.asqcode = aslit.id
left join lit zslit on d.zsqcode = zslit.id
where d.id >= :idinput
/* order by d.id ascending */
into :id, :asterm, :asabk, :asprgm, :assem, :zsterm, :zsabk, :zsprgm,
:zssem, :datum, :proj, :rev, :upddatum, :asdef, :zsdef, :asaudio,
:asvideo,
:asabbildung, :zsabbildung, :zsaudio, :zsvideo, :asverw, :zsverw,
:autor,
:updautor, :asquelle, :zsquelle, :asqcode, :zsqcode, :aut, :updaut
do
begin
counter = counter + 1;
if (counter < 21) then
suspend;
else
exit;
end
./heLen