A class of issues where a database executes a query inefficiently due to the optimiser selecting an innapropriate query plan.

learn more… | top users | synonyms

0
votes
0answers
53 views

SQL-Server 2012: Same query takes different Query Plans - but why?

Recently we had an issue with a query, which reached a timeout when executed the call through our web application. Using a monitoring tool I found the "bad query" and took it. I run it directly on the ...
1
vote
2answers
66 views

Fourth inner join to the same table increases query duration significantly

As soon as I add a fourth inner join to a specific table, the query duration increases significantly: sub 1sec to 45sec. The table in question is deployments d4. The SQL Query: select a.id as ...
0
votes
3answers
46 views

Performance first low, then high after adding index, then keep high after drop index

I am testing performance a complicated select query. It is very slow. using explain, I have found a ALL in type COLUMN. Then I ADD INDEX. result comes out fast. However, when I DROP the INDEX I ...
1
vote
1answer
32 views

How to query a list of all the different errors?

I have a DB which is very big and stores a lot of eventlogs, around 15 million rows. When I try this query, it is totally impossible to get some results. Any idea how I could do this? Maybe indexed ...
2
votes
1answer
34 views

Dramatic decrease in SQL Azure performance after scaling to new edition

Yesterday, we scaled one of our databases in Azure from the old Business edition to the new Standard one (S2). Since then, it has been behaving rather erratically. We have a relatively simple table ...
0
votes
0answers
47 views

Oracle 11 express vs Oracle 11 enterprise performance

We have a very long select query which is executed via our java application through hibernate. This takes 2 seconds to execute on our local Oracle 11 express db server and takes around 22 seconds on ...
1
vote
0answers
37 views

Summing a column based on uniqueness of another column without using temporary table

I have a table like this: CREATE TABLE `files` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `name` varchar(255) NOT NULL, `hash` char(40) DEFAULT NULL, `size` bigint(20) unsigned DEFAULT '0', ...
5
votes
2answers
246 views

Terrible Bad Query Plan

I have a weird query plan problem. I have two databases (Let's call them DB1 and DB2) where both are sitting in the same SQL-Server instance and have identical schema. In there, we have a couple ...
1
vote
1answer
21 views

SQL : get rows from two tables relatively

I've two tables named categories and products. Simple structure is given below. categories cat_id cat_name 1 c1 2 c2 3 c3 products prod_id ...
0
votes
0answers
14 views

SQLServer dependency graph and performance

I have a large stored procedure running on SQLServer2008 to produce a report on the previous day's data. It rehashes data from 12 tables, including a lot of ORDER by date and CASTS. Among others, it ...
1
vote
1answer
27 views

How can I speed up this simple query

I am trying to speed a query that grabs data to be used to display a graph for a research project. It's currently VERY slow. It has 18295603 items only and takes about 20s per query. Here is an ...
0
votes
2answers
51 views

Identical Servers but different query execution plans [duplicate]

We have two server with identical hardware configuration and SQL server configuration. The only difference in the server's being: Server SQL1 - 256 GB RAM Server SQL2 - 128 GB RAM The same database ...
1
vote
1answer
27 views

Deciding which MySQL execution plan is better

Background: I have a query that I'm trying to speed up, involving 3 tables: omgenvelope has 5 million rows omgcust has 195 rows omginput has 35836 rows I'm obtaining the distinct omginputs ...
0
votes
0answers
22 views

How to handle too many instances of multiple tables?

If there is a table accessed by multiple DB threads ( for example 100) at a time then how many instances of that table will be opened? If I run show open tables and see that in_use column value of a ...
2
votes
0answers
28 views

Mysql search matching multiple values in multiple columns

I need to speed up a search. Currently we let our users input a name: John Doe Then in Java we split that string to create multiple values (or "terms") ["John", "Doe"] and loop through the terms ...
1
vote
2answers
103 views

Slow querys on billions-rows-table // index used

Since I'm a young developer and not realy skiled in using databases (PostgreSQL 9.3) i ran into some problems with a project, where i realy need help with. My project is about collecting data of ...
1
vote
0answers
64 views

Odd Execution Plan

I have a table in SQL Server that is performing very slowly and I have been trying different indexing options to try to speed it up to no avail. I suspect all of the varchar(max) fields may be a ...
0
votes
1answer
47 views

MySql: Slow join and group by on indexed columns

The following query takes 15-20s to run SELECT "Trade_US"."ID" AS "Trade_US.ID", "Server_US"."Name" AS "Server_US.Name", "Trade_US"."TradeTypeID" AS "Trade_US.TradeTypeID", "Users"."ID" AS ...
0
votes
1answer
70 views

Slow running aggregate of aggregate query

I am looking for the total balance for all accounts that had a negative balance as of a specific point in time. I've already got the code below, and it works, but works horribly. The transactions ...
1
vote
1answer
31 views

How much should I care about prepared statements for simple queries?

I wonder how much I should care about prepared statements (and therefore try to optimize my code) in case of pretty simple statements. The question originates from the fact that I recently noticed ...
0
votes
0answers
26 views

How does indexes work on an Access query

I'm working on an Access 97 Db and I'm trying to speed up some low performance issues, as of right now I'm wondering how indexes works in Access. Using this table with 300k rows i get awful results ...
0
votes
1answer
28 views

How to optimize a very slow query with joins and group by?

I have this GTFS database : All the ***_id columns are indexed, and there are foreign keys between tables (such as a FK on trips.route_id to routes.route_id). So basically the link between a stop ...
2
votes
3answers
54 views

Change table scan in query plan to seek

I have an ORM generated query (Django) running against a local Postgres 9.1.11 instance that looks up ~5 records from two specific match fields. Due to the nature of the EDI load program, I need to ...
0
votes
1answer
61 views

MySQL SUM with multiple GROUP BY on same table

What is the best way to produce several sum results based on different group by conditions on the same table in MySQL? I believe I'm doing a bad select, but I can't figure out a better way. Imagine ...
1
vote
0answers
60 views

How to use join with this query? [closed]

This query is working fine, and giving the right result. In this query all columns are in one table, but now I have made some changes. Now columns named Semester and Major are in different Table ...
0
votes
2answers
98 views

Tsql Query speed slow due to Or within where clause, causing index scan instead of seek

I have been working on making this query work more efficiently. I found that the number of Ors within the where clause are the biggest problem within this query. This query sits in a stored ...
1
vote
0answers
25 views

Optimization suggestions for db2 materialized view

I have a view for db2 9.7 which has consolidated o/p from few tables. The view is built and it is working fine I want optimization suggestions on the view SQL CREATE VIEW XYZZ AS SELECT ...
1
vote
0answers
24 views

Copying to tmp table slow for query … but only sometimes

I have a query, and I admit it may not be the prettiest query in the world. Sometimes this query runs fairly fast (e.g. 200ms) and other times it runs super slow (e.g. 30s). I don't know why, and ...
0
votes
0answers
12 views

Design and queries for analysis of event-sequences

I will have to store sequences of events with certain properties in a database (MariaDB preferably) and I have some issues regarding the design and queries. The crucial part is the analysis of the ...
0
votes
1answer
69 views

SQL Server sometimes uses a lot more cpu for query

I have a stored procedure with a quite heavy SELECT statement that includes five joins and uses FieldName LIKE '%searchterm%' on multiple columns. This query usually finishes in about 2-5 seconds. But ...
0
votes
2answers
68 views

Querying MySQL, duration increases 10x fold after adding one more Join

I have a somewhat complicated query consisting of many joins on an issue tracker/project management database in MySQL. My issue is that my query was doing OK while I was in the process of building it ...
2
votes
1answer
54 views

Running a query on an improperly indexed, 600gb table

This is my first post on here and I'm really baffled by this. I have joined a team and somewhere in the past a horrific table was created which has been bloated to a point of 600+gb of data. ...
1
vote
1answer
24 views

pt-query-digest results are empty

I have a slow log generated by MySQL 5.1.71-log, that I've copied onto another machine. It appears I'm not getting any results from pt-query-digest. $> pt-query-digest slow.log # 2.1s user time, ...
0
votes
1answer
37 views

Simplifying query by adding Computed Column, performance impact?

The dev team came across the following query (might be incomplete; it's retyped from a screenshot) which had caused slowness: SELECT d.catalogno, d.itemid, SUM(lineamount+taxamount) AS Amount, ...
2
votes
0answers
78 views

SQL Server - Logical Reads lowered, Execution time remained the same

A view executed Select columns from view where col= "date range" (view contains calculation in it Col1+Col2*col3 AS Col4). It took 7 seconds for 500K rows to return, logical reads some 144k. Added ...
2
votes
2answers
57 views

Slow fulltext search due to wildly innacurate row estimates

Fulltext queries against this database (storing RT tickets) seem to be taking a very long time to execute. The attachments table (containing the fulltext data) is about 15GB. The database schema is ...
0
votes
1answer
35 views

Slow response from SELECT query

I have 50 lac rows (i.e. 5 million rows) in student table. I fire select * from student where s_name like('%something word%') limit 0,5. I define indexing on s_name column. That query takes 2 ...
2
votes
2answers
245 views

Get table name from union query?

This is my query SELECT Id, productName, Largeimagepath, Discount, Price, Image FROM tablename1 where Active =1 union SELECT Id, productName, Largeimagepath, Discount, Price, Image FROM tablename2 ...
1
vote
2answers
200 views

Why can't we access SQL Server when a long query is running in Management Studio?

We have a SQL Server Database (2012 Standard edition). The database is accessed through an ASP.Net web page which displays the count of databases in different tables on page load. This work fine ...
0
votes
0answers
32 views

My Query is waiting on “db file sequential read” for 5 minutes and getting timeout after that in Oracle

I have a very simple query when I run it individually from the SQL developer in my oracle database it is running perfectly, but when it is part of application flow then it is failing with timeout and ...
3
votes
1answer
248 views

Optimizing large database query (25+ million rows, using max() and GROUP BY)

I'm using Postgres 9.3.5 and I have a large table in the database, currently it has over 25 million rows and it tends to get even larger rapidly. I'm trying to select specific rows (all unit_ids with ...
0
votes
0answers
16 views

mysql update a table from another table - performance

I have two mysql tables, table_A = 2500000+ (rows) table_B = 6000000+ (rows) I need to update rows in table_A from data in table_B (using a multithreaded application) What is the fastest way ...
0
votes
1answer
76 views

Complicated data

I have a requirement i got from my father. He gave me a table and wanted me to digitalis it. So that he can the system can do all the dirty jobs for him ( that's why there are developers in the world, ...
0
votes
0answers
27 views

Query being executed beyond timeout in a transaction Oracle

I have a simple query as below when executed separately the result is coming very quickly. But when is part of the application flow the same query is being shown as in execution status for more than 5 ...
2
votes
0answers
76 views

Almost identical queries but large time difference in execution

Exhibit A SELECT SUM(value) FROM Credits RIGHT JOIN calendar ON datefield = DATE(FROM_UNIXTIME(created_at)) WHERE confirm = 1 && reason = 1 && country = 'it' && created_at ...
1
vote
1answer
58 views

PostgreSQL: Another seq scan where an index scan is expected

Here's the query: SELECT DISTINCT ON(points.track_id) participants.contest_number, points.track_id, points.lat, points.lon, points.alt, points.timestamp, points.h_speed, ...
0
votes
2answers
82 views

Database SQL Script very, very slow (string manipulation over 700k rows)

I have table containing 700,000 rows containing a string id field with values such as rec-232276-dup-0 and rec-354240-org. The rec- is constant but the other parts of the id can change. I want to ...
0
votes
2answers
78 views

Find the closest bar, when searching for a drink

Problem: Find the closest bar that serves the drink(s) I'm looking for. Here you can find the generated MySQL code http://pastebin.com/5Uc2ewUW The API Request that interacts with this problem ...
0
votes
1answer
82 views

How to increase sql server performance? denormalization (making cascade delete off) vs making duplicate data

I have a database with following related table ( sql server enterptise edtion 2014) each state have many citites which each city has may municpalArea and so on State => Cities = > ...
1
vote
1answer
68 views

MongoDB performance problem

I have a MongoDB for storing result like this {_id, type, imei, lat, lng, spd, dir, time} {_id, type, imei, lac, cid, time} If type is f first one is used and if it is l second one is used. Here ...