MySQL reporting question

der.hans PLUGd at LuftHans.com
Mon Jun 21 23:09:37 MST 2010


moin moin,

t1: t1id, varchar1, stuff
t2: t2id, timestamp, varchar1, varchar2, status

I need to match the most recently entered status from t2 with stuff from
t1 in MySQL.

t2 is grouped by varchar2.

t1 will have millions of rows. t2 has millions of rows and will grow at 4
or 5 times the rate of t1. t2.varchar1 will often be NULL. Non-NULL values
will mostly match up with t1.varchar1. t1.varchar1 can not be NULL.
varchar2 is a clustering of information about varchar1, but usually only
one entry in the cluster will have a value for varchar1.

t1.stuff, t2.status == $some_val where max(t2.timestamp) and t1.varchar1
== t2.varchar1 and t2.varchar2 == t2.varchar2

This is for reporting and will run on a slave.

Any suggestions on how to efficiently build out the report? Unlike my last
DB job, I can create indexes, views, etc.

I can also add columns to either table.

ciao,

der.hans
-- 
#  http://www.LuftHans.com/Classes        http://www.TwoGeekTechs.com/
#  Director of Engineering, FonWallet Transaction Solutions, Inc.
#  If you're not learning, you're not living. - der.hans


More information about the PLUG-discuss mailing list