MySQL Forums
Forum List  »  Perl

Re: Complex multiple command query
Posted by: Rick James
Date: June 27, 2009 12:48PM

Another thing to consider is using AUTO_INCREMENT as a counter, instead of @num variables. It will probably run much faster.

To do so, you need to CREATE TEMPORARY TABLE ... SELECT... And you may need to apply the INDEX after creating that table.

Also look at the compound key trick in MyISAM (not InnoDB) that lets you have
PRIMARY KEY (foo, row_number)
where row_number is AUTO_INCREMENT and starts from 1 for each different 'foo'. This would achieve your "x.row_number <= 2".

There is rarely a real need to send multiple statements at the same time. Your "session" maintains temporary tables and @num values.

Options: ReplyQuote


Subject
Written By
Posted
Re: Complex multiple command query
June 27, 2009 12:48PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.