Re: Performing subtraction between fields

2010-08-21 Thread Dan Nelson
In the last episode (Aug 21), Ashish Mukherjee said: > Well, since you are searching that column, it's probably a good idea. > > Possible scenarios for not storing computed values - > > 1) Data integrity - say, the columns A and B are updated but C does not get > updated, resulting in an anomalo

Re: Slow ALTER TABLE on 70M row InnoDB table

2010-08-21 Thread Eric Bergen
Most alter table operations in 5.0 will rebuild the entire table. The best thing to increase for alter table speed in innodb is the buffer pool. For more details on how innodb handles alter table see http://ebergen.net/wordpress/2007/05/07/how-alter-table-locks-tables-and-handles-transactions/ On

Re: query help

2010-08-21 Thread Travis Ard
Something like this might work: insert into domains select a.accountid, reverse(a.domainid), a.mailname from domains a left outer join domains b on b.domainid = reverse(a.domainid) and b.accountid = a.accountid and b.mailname = a.mailname where b.domainid is null; -Travis

Re: Performing subtraction between fields

2010-08-21 Thread Chris W
If you want C to always be A-B then it would, in my opinion, be a very bad idea to store C in the table. Instead you can just put C in your query. SELECT `A`, `B`, `A` - `B` AS `C` FROM `table` If that seems like a hassle, you could always create a view using that select. Chris W b...@qxhp

Re: Responsibilities of the main mysqld thread?

2010-08-21 Thread Ashish Mukherjee
Couple of thoughts ... lsof -p may give some clue of what files/tables it's reading/writing. From that you may be able to deduce something useful. Check the slow query log and see if any of the queries are CPU-intensive (by doing an EXPLAIN) and are the bottleneck. - Ashish On Fri, Aug 20, 201

Re: Performing subtraction between fields

2010-08-21 Thread Ashish Mukherjee
Well, since you are searching that column, it's probably a good idea. Possible scenarios for not storing computed values - 1) Data integrity - say, the columns A and B are updated but C does not get updated, resulting in an anomalous situation 2) Data-set is large and the extra column leads to

Re: Performing subtraction between fields

2010-08-21 Thread Ashley Stars
Ashish, Mark and off-list responders, Thanks! Ashish, is there a really good general reason not to store a computed value? Searches will be done on this column. Searches like 'Please send me the rows with the ten highest values of C.' > Do you have a really good reason to store a computed value?

Re: Performing subtraction between fields

2010-08-21 Thread Ashish Mukherjee
Do you have a really good reason to store a computed value? It's only useful if you will perform a search on the column, else you could just do the subtraction when you SELECT columns A and B. - Ashish On Sat, Aug 21, 2010 at 11:55 AM, wrote: > Hello, > > For simplicity's sake, let's say I have

Re: Performing subtraction between fields

2010-08-21 Thread Mark Goodge
On 21/08/2010 07:25, b...@qxhp.com wrote: Hello, For simplicity's sake, let's say I have three fields, A, B and C, all of which are integers. I'd like the value of C to be equal to A less B (A-B). Is there a way I can perform this calculation? I'm guessing it would happen when I INSERT a row and