tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David kerber <dcker...@verizon.net>
Subject Re: [OT] Help with java Lists
Date Wed, 12 Dec 2007 15:30:15 GMT
Christopher Schultz wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> David,
>
>   
>> I'm already on my 3rd attempt at optimization for this section.  The
>>  first round was having the db do _all_ the work, submitting a
>> complex query (a view, actually) and returning a resultset with all
>> the data I need. The query took forever, and the java code to produce
>> the report was really fast.
>>     
>
> I would bet on the speed of the (properly indexed and tuned) database
> against Java any day, honestly. These things were built to perform these
>   
The major slowdown in the db is related to a weak (not horrible, but not 
great either) initial db design, plus some design requirements that make 
writing clean queries nearly impossible.  There are some things that 
java (or most any programming language) is better than databases at, and 
the comparing (not just summing up) data from sequential data records is 
one of them (unless you are using a specialized data warehouse database, 
which we are not).

> types of requests. No offense to your abilities, but have you had a DBA
> check out your tables and indexes to see if they are properly supporting
> the queries you are attempting to execute? It's easy to write a
> long-running query, but just a few tweaks can reduce the query time by
> orders of magnitude.
>   
My primary job is database design and management; the java side is where 
I'm weak, and I've spent a LOT of time on these queries, including 
pushing through some design changes that have helped a lot, but not enough.

>> One issue I ran into earlier today with plain HashMaps was that I 
>> couldn't figure out how to search for a specific piece of data, which
>>  requires matching on a site number, a date and a shift, and for some
>>  data another date.
>>     
>
> Right: you need to hash the 3 data items together. Typically, you would
> write a class that bundles the 3 data together and provides a hashCode
> method that incorporates them and an equals method that checks them.
> Then, use that as the key to your map. Is there any reason why you can't
> use the data objects themselves in this way?
>
> map.put(myDataObj, myDataObj)?
>   
I thought of that, but there is a lot more data in the object than just 
the stuff I need to search on.  Once I identify the particular object 
instance I need (which only needs those 3 fields), there are about a 
dozen other fields I need to retrieve from it to process each record.

>   
>> I have a workable solution right now, though the code is rather more
>> complex than I would like to keep my navigation of all those TreeMaps
>> in sync.
>>     
>
> When in doubt, abstract: write yourself a helper class that bundles all
> this odd logic together. Then, your business code will be a lot simpler
> to read, and you can separately unit test your
> SpecializedTreeSetHashMapLinkedList class (or whatever). ;)
>   
Yeah, that's what I'm working on right now.  It's coming together, 
though somewhat slowly since I'm still getting my head around the 
different kinds of maps and lists, and what each of them is good for.

Thanks!
D



---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message