Why does this query take so long?

2009-12-27 Thread René Fournier
So... there is an index, and it's supposedly used: mysql EXPLAIN SELECT id, province, latitude, longitude, AsText(coordinates), s_ts_r_m, quartersection FROM qs WHERE MBRContains(GeomFromText('POLYGON((51.62582589 -114.82248918,51.65126254 -114.82248918,51.65126254 -114.78150333,51.62582589

last_insert_id

2009-12-27 Thread Victor Subervi
Hi; mysql select * from products;

Re: last_insert_id

2009-12-27 Thread Mattia Merzi
2009/12/27 Victor Subervi victorsube...@gmail.com: mysql select * from products; [...] mysql select last_insert_id() from products; [...] Now, I was expecting 1, not 0! What up? [...] LAST_INSERT_ID() (no arguments) returns the first automatically generated value successfully inserted for an

Re: last_insert_id

2009-12-27 Thread Victor Subervi
On Sun, Dec 27, 2009 at 11:27 AM, Mattia Merzi mattia.me...@gmail.comwrote: 2009/12/27 Victor Subervi victorsube...@gmail.com: mysql select * from products; [...] mysql select last_insert_id() from products; [...] Now, I was expecting 1, not 0! What up? [...] LAST_INSERT_ID() (no

Re: last_insert_id

2009-12-27 Thread Michael Dykman
last_insert_id() returns the last id auto-incremented in *the current session*. If you disconnect and reconnect, it can not be retrieved. - michael dykman On Sun, Dec 27, 2009 at 11:42 AM, Victor Subervi victorsube...@gmail.com wrote: On Sun, Dec 27, 2009 at 11:27 AM, Mattia Merzi

Re: last_insert_id

2009-12-27 Thread Victor Subervi
On Sun, Dec 27, 2009 at 12:00 PM, Michael Dykman mdyk...@gmail.com wrote: last_insert_id() returns the last id auto-incremented in *the current session*. If you disconnect and reconnect, it can not be retrieved. Ahah! So how do I retrieve the last id inserted irrespective of connection? TIA,

Re: last_insert_id

2009-12-27 Thread Gary Smith
Victor Subervi wrote: On Sun, Dec 27, 2009 at 12:00 PM, Michael Dykman mdyk...@gmail.com wrote: last_insert_id() returns the last id auto-incremented in *the current session*. If you disconnect and reconnect, it can not be retrieved. Ahah! So how do I retrieve the last id inserted

Re: last_insert_id

2009-12-27 Thread Steve Edberg
At 11:13 AM -0500 12/27/09, you wrote: Hi; mysql select * from products;

Re: last_insert_id

2009-12-27 Thread Victor Subervi
On Sun, Dec 27, 2009 at 1:30 PM, Gary Smith li...@l33t-d00d.co.uk wrote: Victor Subervi wrote: On Sun, Dec 27, 2009 at 12:00 PM, Michael Dykman mdyk...@gmail.com wrote: last_insert_id() returns the last id auto-incremented in *the current session*. If you disconnect and reconnect, it

Re: last_insert_id

2009-12-27 Thread Gary Smith
Steve Edberg wrote: (2) autoincrement values are not reused after deletion, so if you deleted the record with ID=1000 inserted in (1), the next autoincrement would still be 1001, even if the existing records are IDs 1,2,3. This is usually the desired behavior, but again, may not be what *you*

Re: last_insert_id

2009-12-27 Thread Carsten Pedersen
Gary Smith skrev: ... An example of where it wouldn't be: Although ID is auto_increment, you could define a row as, say, '10005583429'. This would be a valid input. Selecting max(id) would return that number. However, auto_increment wouldn't change - it would still be '34' (or whatever) for

Re: last_insert_id

2009-12-27 Thread Mark Goodge
Gary Smith wrote: Steve Edberg wrote: (2) autoincrement values are not reused after deletion, so if you deleted the record with ID=1000 inserted in (1), the next autoincrement would still be 1001, even if the existing records are IDs 1,2,3. This is usually the desired behavior, but again, may

Is there a better way than this?

2009-12-27 Thread Tim Molter
I'm new to MySQL and I'm looking for some guidance. I have a table A, with two columns X and Y with the following data: | X|Y| 1 24 1 25 2 25 2 26 3 27 I want my SQL query to return 2 following this verbose logic:

Re: Is there a better way than this?

2009-12-27 Thread John List
On 12/27/2009 06:04 PM, Tim Molter wrote: I'm new to MySQL and I'm looking for some guidance. I have a table A, with two columns X and Y with the following data: | X|Y| 1 24 1 25 2 25 2 26 3 27 I want my SQL query

Re: Is there a better way than this?

2009-12-27 Thread Chris W
Unless I am missing something, this should work. SELECT DISTINCT X FROM `A` WHERE Y IN (25) AND Y NOT IN (24) Chris W Tim Molter wrote: I'm new to MySQL and I'm looking for some guidance. I have a table A, with two columns X and Y with the following data: | X|Y| 1

Re: Why does this query take so long?

2009-12-27 Thread René Fournier
So just to clarify (hello?), the index which *should* be used (EXPLAIN says so) and *should* make the query run faster than 4 seconds either isn't used (why?) or simply doesn't speed up the query (again, why?).

Re: Why does this query take so long?

2009-12-27 Thread René Fournier
Hmm, weird. I just re-imported the data (after drop/create table, etc.), and now the spatial queries run fast. Has anyone seen this sort of thing happen? Maybe the Index got corrupted somehow, and then MySQL had to do a full table scan (even though EXPLAIN indicated it would use the Spatial