All Questions
5 questions
1
vote
3
answers
288
views
MYSQL Update data based on top 10 records of each user
I have a table users and other table user_scores. In user_scores, I save daily score of every user based on a algorithm. Now I want to calculate AVG user_score by only considering latest 10 records of ...
0
votes
0
answers
130
views
MySQL - Counting multiple parameters from the same subquery
I have a very large MySQL (~10M rows) database, currently using the InnoDB engine, which stores log events. I am working on a front-end that allows searching through this log database, and one of the ...
2
votes
2
answers
2k
views
Slow CREATE table from subquery using SELECT .. INNER JOIN
This query takes ~90 seconds:
CREATE TABLE filtered
(
SELECT DISTINCT
f2.cityCode,
f2.productCode,
f2.productDesc,
f2.inventoryDate,
f2.inventoryLevel
FROM
etm
...
5
votes
1
answer
987
views
Why does IN (subquery) perform bad when = (subquery) is blazing fast?
Have a look at these two queries:
Simple:
mysql> SELECT * FROM omgbatch JOIN omgoutput ON (idomgbatch=omgbatch) WHERE idomgoutput = (SELECT DISTINCT lastoutput FROM omgenvelope WHERE lastinput=18658);...
13
votes
4
answers
21k
views
MySQL subquery slows down drastically, but they work fine independently
Query 1:
select distinct email from mybigtable where account_id=345
takes 0.1s
Query 2:
Select count(*) as total from mybigtable where account_id=123 and email IN (<include all from above ...