On 3/10/06, Dave Merrin <dmerri..pasystems.co.uk> wrote:
>
> Hi,
>
> I'm trying to do some optimising for my application. I'm currently looking
> at prefetching. Is there any way to count how many sql queries are made by
> cayenne during a period of time? I'd ideally like to be able to pick up on
> an event every time cayenne runs an sql query. I can't just count the
> queries I'm making as I'm using the 'to' methods which are implicitly
> running queries.
Well, a number of methods come to mind:
1. write your own wrapper method arround dataContext.performQuery and use
it, instead of the wrapped method itself - put as much logging logic in your
wrapper
2. use AOP and attach counter code to the performQuery method - that way you
can easily remove this code when you deploy the app
3. use log4j and simply run something like "grep performQuery app.log | wc
-l" and you get a total query number...it's not that hard to do the same for
a defined time interval.
4. change the cayenne source: change the performQuery method so that _it_
logs everything for you...but this really isn't needed: if you use log4j and
set a low enough log level threshold, you'll find that cayenne already does
a lot of detailed logging anyway
5. use a RMBMS-specific tool (postgresql instrumentation or MSSQL Profiler,
just to name a couple) designed to monitor performance
6. look at the db server's HD LED and count the number of times it blinks
during server operation...although, this procedure could produce less than
reliable results if the dataset fits into memory :)
Tomislav
This archive was generated by hypermail 2.0.0 : Fri Mar 10 2006 - 06:56:04 EST