Subject | Re: does firebird always go fastest way? |
---|---|
Author | martinknappe |
Post date | 2006-05-17T11:22:49Z |
ok, i figure the answer to my initial question is then no..i've read
about 'join' before but i never got too familiar with it so i just
stuck to composing my sql-queries of combinations of "select * from
(select ...)"-statements because i thought join was only there for the
sake of readability (which i don't really care about) but if it really
makes my search faster then it seems i'd indeed better do some reading
up :-)
--- In firebird-support@yahoogroups.com, "Martijn Tonies"
<m.tonies@...> wrote:
about 'join' before but i never got too familiar with it so i just
stuck to composing my sql-queries of combinations of "select * from
(select ...)"-statements because i thought join was only there for the
sake of readability (which i don't really care about) but if it really
makes my search faster then it seems i'd indeed better do some reading
up :-)
--- In firebird-support@yahoogroups.com, "Martijn Tonies"
<m.tonies@...> wrote:
>wrote:
>
>
>
> > this query takes a couple seconds with dicentries containing some
> > 100000 entries!
>
> Which doesn't mean it couldn't run much faster if you used a JOIN :-)
>
> Let alone being it much more clear to read.
>
> Martijn Tonies
> Database Workbench - development tool for Firebird and more!
> Upscene Productions
> http://www.upscene.com
> My thoughts:
> http://blog.upscene.com/martijn/
> Database development questions? Check the forum!
> http://www.databasedevelopmentforum.com
>
> > --- In firebird-support@yahoogroups.com, Helen Borrie <helebor@>
> > >awkward
> > > At 07:32 PM 17/05/2006, you wrote:
> > > >hello
> > > >i have a very rudimentary knowledge of sql as it's only one part of
> > > >the project im in right now and in order to find records in my
> > > >database i have my delphi application generate sometimes very
> > > >queries and like for example(select *
> > > >
> > > >select * from (select * from (select * from (select * from
> > > >from dicentries where id in (select id_dicentry fromwhere
> > > >dskrptlink_dicentries where id_dskrpt = (select id from dskrpts
> > > >asdskrpt = 'ios'))) where id in (select id_dicentry fromwhere
> > > >dskrptlink_dicentries where id_dskrpt = (select id from dskrpts
> > > >asdskrpt = 'iop'))) where id in (select id_dicentry fromwhere
> > > >dskrptlink_dicentries where id_dskrpt = (select id from dskrpts
> > > >asdskrpt = 'ois'))) where id < 2067 order by id descending rows 20)key on
> > > >order by id ascending
> > > >
> > > >(for some clarity: dskrptlink_dicentries.id_dicentry = foreign
> > > >dicentries.id; dskrptlink_dicentries.id_dskrpt = foreign key onasdskrpt =
> > > >dskrpts.id => dskrptlink_dicentries is table establishing a
> > > >many-to-many link between tables dicentries and dskrpts...so this
> > > >query would ask for the last 20 of all those records in dicentries
> > > >that are linked via dskrptlink_dicentries to ALL three records in
> > > >dskrpts where dskrpts.asdskrpt = 'ois', asdskrpt = 'iop',
> > > >'ios' and then order them ascendingly)worth
> > > >
> > > >i'm pretty sure if i had better knowledge of sql there would be an
> > > >easier way to express the same thing but my question is: is it
> > > >it? will it make my searches faster or can i assume that firebirdput it
> > > >always looks for the fastest way possible?
> > >
> > > Your question comes into the category "How long is a piece of
> > > string?" If this query actually runs at all (doubtful) it will
> > > probably take a week or two to complete.
> > >
> > > Is it worth understanding the SQL language to use Firebird? Yes.
> > > (understatement!!).
> > >
> > > I think I might add your posting to my forthcoming book, "Essential
> > > SQL for Skateboard Riders". :-)
> > >
> > > Get your best SQL textbook and look up the keyword JOIN. If you
> > > don't own an SQL textbook and you have a birthday coming soon,
> > > at the top of your wish-list. If you attend an IT school, visit the
> > library.
> > >
> > > ./heLen
>