Re: Sum of counts

2006-05-10 Thread Adam Wolff
You could you use UNION to make this all execute in a single query. On 5/10/06, Rhino <[EMAIL PROTECTED]> wrote: Hi Chris, Joerg, and everyone else following this discussion, Joerg, you are correct; the best way to sum the tables is individually and then add the sums together with program logic

Re: slow query

2006-05-10 Thread Adam Wolff
column: > http://dev.mysql.com/doc/refman/5.0/en/alter-table.html > Also note that as you add or delete rows the table does not stay in order. > > Hope this helps! > > Dan > > > Adam Wolff wrote: > > I have a very simple table that looks like this: > > CREATE

slow query

2006-05-09 Thread Adam Wolff
I have a very simple table that looks like this: CREATE TABLE `contacts` ( `id` int(11) NOT NULL auto_increment, `fullname` varchar(100) default NULL, `user_id` int(11) NOT NULL, PRIMARY KEY (`id`), KEY `user_id` (`user_id`), KEY `user_id_2` (`user_id`,`fullname`), CONSTRAINT `contacts_ibfk_1` FO

Re: Optimising for many rows and returned records (de-coupling query time to record set size for range queries)

2006-04-24 Thread Adam Wolff
Well, I hadn't known about the spatial features of MySQL. If you're ok using vendor extensions then that definitely looks like the way to go: http://dev.mysql.com/doc/refman/5.0/en/gis-introduction.html A On Apr 24, Nick Hill wrote: > Hello Adam > > Adam Wolff wrote: > &

Re: Optimising for many rows and returned records (de-coupling query time to record set size for range queries)

2006-04-23 Thread Adam Wolff
Actually I think this should be an INNER JOIN -- not a LEFT JOIN. A On Apr 23, Adam Wolff wrote: > I didn't look through your code very carefully. Have you confirmed (using > EXPLAIN) that your select query is using the index? > > I don't much about the mysql optimizer,

Re: Optimising for many rows and returned records (de-coupling query time to record set size for range queries)

2006-04-23 Thread Adam Wolff
I didn't look through your code very carefully. Have you confirmed (using EXPLAIN) that your select query is using the index? I don't much about the mysql optimizer, but it's possible that this query: > $query1="SELECT lat,lon from integer_test WHERE lat>$lat1 and lat<$lat2 > and lon>$lon1 and l

Re: Why does this query takes a lot of time

2006-04-22 Thread Adam Wolff
On Apr 22, Philippe Poelvoorde wrote: > alter table s add index(login_name); > alter table c add index(recordID); To make this much faster, I think you may want: alter table s add index(recordID, login_name); alter table c add index(recordID); Because after the join, the engine can use the

Re: newbie optimization question

2006-04-20 Thread Adam Wolff
Hey! I figured out this one myself: On Apr 19, Adam Wolff wrote: > * Question 2: > Why does introducing an extra WHERE clause make things slower? > If I do this: > SELECT * FROM contacts WHERE fullname LIKE "j%" AND user_id=1 > ORDER BY fullname LIMIT 10; >

finding a record within a sort order

2006-04-20 Thread Adam Wolff
I have a table with a large number of rows. I have the primary key for a record within the table. The record I'm looking for looks like this: +++---+ | id | fullname | email | +++

Re: newbie optimization question

2006-04-20 Thread Adam Wolff
lly have 3! combinations of filters and sort orders. Adam On Apr 20, Alexey Polyakov wrote: > On 4/20/06, Adam Wolff <[EMAIL PROTECTED]> wrote: > > > How can I optimize the case where I filter on one key but sort on another? > > This is fast: > >SELECT * FROM co

newbie optimization question

2006-04-19 Thread Adam Wolff
Hi. I'm new to database optimization and I have a couple of questions. I have a table like this: +++-+-+ | id | fullname | email | user_id | +++-+-+ Where fullname and email are varchar(100) a