The tag refers to how to make SQL queries run more efficiently. Some of these questions may belong on DBA.stackexchange.com, especially if they involve reindexing, query plans, etc. SQL Queries can take a long time to run if written badly, or on huge amount of data. Performance can be crucial ...
2
votes
1answer
16 views
MySQL index in between where clause and order by clause
My table structure is something like below:
CREATE TABLE test (
id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
field_1 VARCHAR(60) NOT NULL,
field_2 INT(10) UNSIGNED NULL,
field_3 ...
3
votes
2answers
42 views
Should I process a large amount of data with SQL or Ruby? [closed]
I have a MySQL table with hundreds of thousands of entries in it.
I need to specify a date range and select all the entries between those two dates. I then need to break down the entries hour by hour ...
0
votes
1answer
25 views
optimizing a query using union left joins and inner joins
I have a query that I want to optimize. Both unions executed separatley run fine, however as soon as I include inner join it takes up to 57 seconds. How do I solve this. My query is as follows
SELECT
...
2
votes
1answer
27 views
MySQL query optimization with between or larger than > condition
Problem: slow query.
table1 has about 5 000 rows
table2 has about 50 000 rows
timestamp format is int(11)
MySQL - 20 seconds (with indexes)
PostgreSQL - 0,04 seconds (with indexes)
SELECT *
FROM ...
0
votes
2answers
19 views
Need help optimizing an sql statement with several “field IN (subselect)” OR'd together
Please advise how best to optimize this query.
select count(*)
from table1
where field1 in (select `text` from table2 where id=2)
or field2 in (select `text` from table2 where id=2)
or field3 ...
-1
votes
1answer
18 views
Optimizing query using joins in mysql
I have a query I would like to optimize, It takes 29 seconds to complete. I have tried creating a view of the union join but gives worse result.
select o.orderno, o.orderdate, c.lastname
from ...
0
votes
1answer
39 views
Can we optimize this SQL Query?
I have this Query that takes at least 1 minute to run. It uses a lot of Left Joins.
Is there any way to make it faster ? I'm new to SQL, so help would be appreciated.
SELECT
distinct ...
1
vote
0answers
24 views
Optimizing big SQL migrations
Is there a tool that detects "inverse" operations (like add column/table in the beginning, drop it later) in a big (1800 statements) migration script?
1
vote
2answers
65 views
How can reduce the time of query
I have a table called ResultValues where I have 6 columns, 4 are integers, 1 is datatime and 1 is varbinary (1640).
Total number of records are '27,389,918' so this table is very huge. now when i ...
0
votes
2answers
207 views
Hbase Schema design
I have to design an Hbase table to store users information, this information is targeted for social networking, like: age, sex, education, hobbies, read books, traveled countries ...
NOTE: we could ...
-3
votes
1answer
38 views
Can this join be executed in under a second [closed]
Table Foo columns:
FooID INT
Value VARCHAR(1000)
Table Bar columns:
BarID INT
Value VARCHAR(1000)
Foo contains 250.000.000 rows, bar contains 1.500.000 rows
Is it possible to join on Foo.FooID ...
0
votes
1answer
26 views
Postgres Bulk Data Import and Populate Associated Data
I have a Postgres database that gets updated from various external sources several times a day, and each record has fields like company_id and user_id that need to get looked up from an existing table ...
0
votes
2answers
29 views
How to reduce scope of subquery?
I've got SQL running on MS SQL Server similar to the following:
SELECT
CustNum,
Name,
FROM
Cust
LEFT JOIN (
SELECT
CustNum, MAX(OrderDate) as LastOrderDate
FROM
...
0
votes
1answer
24 views
mysql table design for daily rotation of top rating
I store top-views and 'likes' in a table called 'counts'. Once a night I run this query
UPDATE `counts` SET rank=d7+d6+d5+d4+d3+d2+d1,d7=d6,d6=d5,d5=d4,d4=d3,d3=d2,d2=d1,d1=0
Each day of the week ...
0
votes
0answers
23 views
Slow query because of rows?
Note: 0 rows are returned.
My query is 17.88 seconds. I don't know why. Any idea what I can do to make this faster? I specifically am a bit confused why derived2 has no index. I know the subquery ...