Hello!

Question: Can I rely on the following behaviour?
mysql> create table test(id integer not null auto_increment primary key, t
char(15));
mysql> insert into test(t) values (last_insert_id());
mysql> insert into test(t) values (last_insert_id()+1);
mysql> select * from test;
+----+------+
| id | t    |
+----+------+
|  1 | 0    |
|  2 | 2    |
+----+------+
That is - when used in an insert statement the last_insert_id() returns the
value BEFORE the insert?
This is useful when storing hierarchical data in a table by using char() to
store "ancestorid.parentid.objectid."

Suggestion: Document this behaviour.


Question/Suggestion#2:
1. note that any ASCII string can be converted to an approximate real number
between 0 and 1 by using the first few chars as base256 digits following the
decimal separator. With a little work you probably can do the same thing
with international charsets.
2. you can compute incrementally the min,max,count, sum and sum of squares
for these numbers for each column. This in turn can provide you with an
approximate statistics of the data in the column assuming gauss
distribution.
3. With a good estimate of the statistics you can figure out an estimate how
many rows you can get for each filtering condition. This can help selecting
indices as well as master tables for joins.

The question is: do you use this trick?

Thanks,
Mircea.




---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to