Re: Performance Query
[prev]
[thread]
[next]
[Date index for 2004/09/07]
On Tue, Sep 07, 2004 at 08:30:15AM +0100, tom@xxxxxxxx.xxx wrote:
> Assuming this has been 'modelled' with the use of the "has_a"
> Class::DBI methods (because that is the best way to do it with
> Class::DBI?) on the User class - how many hits are there actually to
> the database?
Although Tony did not address this question, I think you are correct.
> The first SQL is 1 query with 1 overhead retriving X rows and the 2nd
> loop is 1+X*3 queries retrieving X+1 rows. My worries are that if I
> start retrieve a few thousand rows, instead of 1 query, I have 3000+
> queries to the database. Make this a web site with a few concurrent
> visitors and suddenly I am hitting the database with 10,000 queries?
> To me that is a performance issue.
I'd agree with Tony to look at why you are retrieving 1000 rows for a
request. If you decide that it's vitally important to retrieve all 1000
and a code profile has shown that CDBI is where your slowdown is really
at, then you can use set_sql to create a custom sql statement that
returns exactly what you need. Check the docs and the wiki for examples
(particularly the recipe about joins).
HTH,
William
--
Knowmad Services Inc.
http://www.knowmad.com