Re: CURRENT insert ID

2011-01-21 Thread Jesper Wisborg Krogh
Hi, On 22/01/2011, at 11:27 AM, Donovan Brooke wrote: > Just an idear.. > > Don't auto_increment the main table.. create a unique Id table, > auto_increment that, and grab that value first for use with both fields in > your main table. This can be wrapped into a trigger, so the main table fun

Re: CURRENT insert ID

2011-01-21 Thread Donovan Brooke
Just an idear.. Don't auto_increment the main table.. create a unique Id table, auto_increment that, and grab that value first for use with both fields in your main table. Donovan -- D Brooke -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:h

Re: Slow query on MySQL4 server doing simple inner join of two InnoDB tables

2011-01-21 Thread Kendall Gifford
On Fri, Jan 21, 2011 at 2:01 PM, Shawn Green (MySQL) < shawn.l.gr...@oracle.com> wrote: > On 1/21/2011 14:21, Kendall Gifford wrote: > >> Hello everyone, I've got a database on an old Fedora Core 4 server running >> MySQL 4 (mysql-server.x86_64 4.1.12-2.FC4.1). The database in question has >> just

Re: Slow query on MySQL4 server doing simple inner join of two InnoDB tables

2011-01-21 Thread Shawn Green (MySQL)
On 1/21/2011 14:21, Kendall Gifford wrote: Hello everyone, I've got a database on an old Fedora Core 4 server running MySQL 4 (mysql-server.x86_64 4.1.12-2.FC4.1). The database in question has just two (InnoDB) tables: messages (approx 2.5 million records) recipients (approx 6.5 million records)

RE: CURRENT insert ID

2011-01-21 Thread Jerry Schwartz
>-Original Message- >From: Michael Dykman [mailto:mdyk...@gmail.com] >Sent: Friday, January 21, 2011 1:27 PM >To: Jerry Schwartz >Cc: MySql >Subject: Re: CURRENT insert ID > >You don't need to do an update: > >... > >new.xxx = new.id >... > [JS] I wish it were that easy. new.id is null unti

RE: CURRENT insert ID

2011-01-21 Thread Jerry Schwartz
>-Original Message- >From: João Cândido de Souza Neto [mailto:j...@consultorweb.cnt.br] >Sent: Friday, January 21, 2011 12:47 PM >To: mysql@lists.mysql.com >Subject: Re: CURRENT insert ID > >Ok, you must have your own reasons to do that. > >The fact is: You can´t set the auto_incremente

Re: Slow query on MySQL4 server doing simple inner join of two InnoDB tables

2011-01-21 Thread Reindl Harald
you need hughe ram / innodb_buffer_pool for large datasets in a perfect world the buffer_pool is as large as the data how looks your current config? how much RAM has the machine? Am 21.01.2011 20:21, schrieb Kendall Gifford: > Hello everyone, I've got a database on an old Fedora Core 4 server run

Is is possible to update a column based on a REGEXP on another column?

2011-01-21 Thread Phil
I have a table which contains a username column which may be constructed something like somename[A] or [DDD]someothername The A or DDD can be anything at all. I've added a new column to the table to which I'd like to populate with the value within the square brackets. I

Slow query on MySQL4 server doing simple inner join of two InnoDB tables

2011-01-21 Thread Kendall Gifford
Hello everyone, I've got a database on an old Fedora Core 4 server running MySQL 4 (mysql-server.x86_64 4.1.12-2.FC4.1). The database in question has just two (InnoDB) tables: messages (approx 2.5 million records) recipients (approx 6.5 million records) These track information about email message

Re: CURRENT insert ID

2011-01-21 Thread Michael Dykman
You don't need to do an update: ... new.xxx = new.id ... On Fri, Jan 21, 2011 at 12:20 PM, Jerry Schwartz wrote: >>-Original Message- >>From: Jerry Schwartz [mailto:je...@gii.co.jp] >>Sent: Friday, January 21, 2011 11:56 AM >>To: 'Michael Dykman'; 'MySql' >>Subject: RE: CURRENT insert I

Re: best way to have a unique key

2011-01-21 Thread Michael Satterwhite
On Friday, January 21, 2011 09:23:47 am Jerry Schwartz wrote: > > [JS] A UUID (what Microsoft calls a GUID) is based in part on the MAC > address of the generating device. Since MAC addresses are supposed to be > unique across the known universe, so should a UUID. > Not entirely true - and even

Re: [PHP] Organisational question: surely someone has implemented many Boolean values (tags) and a solution exist

2011-01-21 Thread David Harkness
On Fri, Jan 21, 2011 at 4:44 AM, Dotan Cohen wrote: > Then I would have to check what values are available when inserting, > and possibly normalise every so often. I'll think about that, and when > I have enough data in the database I'll set up a test system to play > with the possibility. > Yes

Re: CURRENT insert ID

2011-01-21 Thread Jo�o C�ndido de Souza Neto
Ok, you must have your own reasons to do that. The fact is: You can´t set the auto_incremente value field to another field in the same table and record even in a trigger. So, the best way is a second update. -- João Cândido de Souza Neto "Darryle Steplight" escreveu na mensagem news:AANL

Re: CURRENT insert ID

2011-01-21 Thread Darryle Steplight
@Joao - I'm currently building a database out right now that has this scenario. One field can be the primary key, that has a purpose for holding the record id, another field can hold the value. Let say there are two fields, id, s_id. Initially, you insert a record and `id` is now 100 and you update

Re: CURRENT insert ID

2011-01-21 Thread Jo�o C�ndido de Souza Neto
I can´t think about how useful for you would be to have two fields with the same value. -- João Cândido de Souza Neto ""Jerry Schwartz"" escreveu na mensagem news:007501cbb98a$177acba0$467062e0$@co.jp... Here it is in a nutshell: I have a field that needs to be set equal to the auto-inc

RE: CURRENT insert ID

2011-01-21 Thread Jerry Schwartz
I made a typo in my previous message. >-Original Message- >From: Jerry Schwartz [mailto:je...@gii.co.jp] >Sent: Friday, January 21, 2011 12:20 PM >To: 'Jerry Schwartz'; 'Michael Dykman'; 'MySql' >Subject: RE: CURRENT insert ID > >>-Original Message- >>From: Jerry Schwartz [mailto:j

RE: CURRENT insert ID

2011-01-21 Thread Jerry Schwartz
>-Original Message- >From: Jerry Schwartz [mailto:je...@gii.co.jp] >Sent: Friday, January 21, 2011 11:56 AM >To: 'Michael Dykman'; 'MySql' >Subject: RE: CURRENT insert ID > >>-Original Message- >>From: Michael Dykman [mailto:mdyk...@gmail.com] >>Sent: Friday, January 21, 2011 11:50

RE: CURRENT insert ID

2011-01-21 Thread Jerry Schwartz
>-Original Message- >From: Michael Dykman [mailto:mdyk...@gmail.com] >Sent: Friday, January 21, 2011 11:50 AM >To: MySql >Subject: Re: CURRENT insert ID > >I think an ON INSERT TRIGGER would take care of this; can't think of >any other way. Using last_insert_id() in the argument list would

Re: CURRENT insert ID

2011-01-21 Thread Michael Dykman
I think an ON INSERT TRIGGER would take care of this; can't think of any other way.  Using last_insert_id() in the argument list would likely yield you the previous value (which might not even related to your table. Having siad that..   odd requirement.  - michael dykman ps -- sorry for the

RE: best way to have a unique key

2011-01-21 Thread Jerry Schwartz
>-Original Message- >From: Michael Dykman [mailto:mdyk...@gmail.com] >Sent: Friday, January 21, 2011 11:35 AM >To: Johan De Meersman >Cc: Anthony Pace; mysql. >Subject: Re: best way to have a unique key > >One of the components of the UUID is drawn form the mac address of the >server.. Whi

CURRENT insert ID

2011-01-21 Thread Jerry Schwartz
Here it is in a nutshell: I have a field that needs to be set equal to the auto-increment ID as a record is entered. I don’t know how to do this without a subsequent UPDATE (which I can do with a trigger). Is there any way to avoid the cost of an UPDATE? Here’s a more concrete descrip

Re: best way to have a unique key

2011-01-21 Thread Michael Dykman
One of the components of the UUID is drawn form the mac address of the server.. While in practice this is not true of all systems (except from http://dev.mysql.com/doc/refman/5.0/en/miscellaneous-functions.html#function_uuid) Currently, the MAC address of an interface is taken into a

Re: optimizing query

2011-01-21 Thread Simon Wilkinson
Thanks for the suggestions everybody. I added in columns to store the day, month and year of the created_at value, and then added in an index on (newsletter_id, created_month, created_day), and the the slow queries reduced from around 20 seconds to 0.5 seconds! I also removed the redundant indexe

RE: best way to have a unique key

2011-01-21 Thread Jerry Schwartz
>-Original Message- >From: vegiv...@gmail.com [mailto:vegiv...@gmail.com] On Behalf Of Johan De >Meersman >Sent: Friday, January 21, 2011 1:22 AM >To: Anthony Pace >Cc: Michael Dykman; mysql. >Subject: Re: best way to have a unique key > >I have to say, something similar was my first though

Re: [PHP] Organisational question: surely someone has implemented many Boolean values (tags) and a solution exist

2011-01-21 Thread Dotan Cohen
On Fri, Jan 21, 2011 at 12:29, Richard Quadling wrote: > Changing data in a database is the role of the database engine. It is > much more efficient to have the cost on the insert than it is on the > select. > Agreed. On insert I could even delegate the operation to another thread which does not

Re: [PHP] Organisational question: surely someone has implemented many Boolean values (tags) and a solution exist

2011-01-21 Thread Dotan Cohen
> Yes, and an edge list model may perform better in other respects too: > > http://www.artfulsoftware.com/mysqlbook/sampler/mysqled1ch20.html > http://www.artfulsoftware.com/mysqlbook/sampler/mysqled1ch20.html > Thanks. I am currently reading "Trees and Hierarchies in SQL for Smarties" by Joe Celk

Re: [PHP] Organisational question: surely someone has implemented many Boolean values (tags) and a solution exist

2011-01-21 Thread Dotan Cohen
> If you are doing this often, you could leave spaces in the left and right > values so that you could minimize the number of rows that need to be > updated. The article makes every leaf use x and x+1 for left and right which > forces another update to add a child. If instead you used x and x+20 yo

Re: [PHP] Organisational question: surely someone has implemented many Boolean values (tags) and a solution exist

2011-01-21 Thread Dotan Cohen
>> Actually, I'm the customer! But assuming that a customer exists, that >> implies compensation, and therefore fair bait. > Then that's different altogether. you get to decide what information > is displayed, and what information is 'sensed', and on what platform. > Yes, but before I get to that

Re: [PHP] Organisational question: surely someone has implemented many Boolean values (tags) and a solution exist

2011-01-21 Thread Richard Quadling
On 20 January 2011 19:20, Dotan Cohen wrote: > On Thu, Jan 20, 2011 at 19:21, Richard Quadling wrote: >>> That is terrific, at least the first half. The second half, with the >>> Venn diagrams, is awkward! >> >> When you get heavily nested data, the adjacent list model (where you >> have a parent