Subject [firebird-support] Re: Newbie: Query speed and DB size
Author Svein Erling Tysvær
Adam wrote:
>> 2) Does the query speed depend on the number of columns in a table,
>> assuming that I will only query the PK column (select ID from mytable)?

>It is certainly dependent on the number of fields returned, but I have never observed performance penalties >based on fields not returned.

I did observe such a performance penalty yesterday! Though admittedly, that was within an WHERE EXISTS(SELECT ...) construct, the table that was queried within the EXISTS contained over 1000 columns, and it was a small penalty.

Kogerbnz wrote:

>I'm not expecting an exact answer, I'm just trying to get a little
>feeling with how the DB would perform.
>Which would guide me when deciding if I should try optimize my design
>to use fewer queries, but giving a bit messier table design.

What can be important if having several queries, is to used prepared queries wherever there is a chance of them being reused, i.e. use

select ID from mytable where pk = :pk

prepare it once, then assign the parameter before opening, rather than repeatedly using

select ID from mytable where pk = 1
select ID from mytable where pk = 2
...

You may get better advice if telling a bit more about what you're actually trying to design.

HTH,
Set