All Questions
Tagged with sqlperformance or query-optimization
11,570 questions
0 votes
1 answer
132 views
Make MySQL evaluate subquery first
SELECT tt.trans_type_name AS transaction_type, trans.transaction_time, a.trans_action_name AS transaction_action_name, trans.transaction_notes FROM(SELECT Cast(...
3 votes
1 answer
95 views
Cause of and means to avoid "flat BNL join" in mariadb 10.11
I'm trying to help a user in another stackoverflow question and have bumped by head into a strange behaviour. As I rarely use MariaDB, I'm opening another question to investigate the behaviour, ...
0 votes
1 answer
54 views
AWS Glue Script Scanning Entire Table Despite Date Filter
I have written a small Glue script that fetches some data between two dates, but I found that it scans the entire table instead of just the data within the specified time range. I also tried creating ...
Advice
0 votes
6 replies
96 views
Why MariaDB doesn't use newly added index?
MariaDB version is 10.4.34. The query looks like: SELECT bet.* FROM Bet bet WHERE bet.placed >= '2025-10-29T00:00:00' AND bet.placed <= '2025-10-29T23:59:59' AND EXISTS ( SELECT 1 FROM ...
0 votes
1 answer
213 views
Make Postgres query fast without UNION
The ORDMBS is PostgreSQL 17.5 on x86_64-suse-linux-gnu, compiled by gcc (SUSE Linux) 7.5.0, 64-bit. I have big table (about 150 GB), partitioned. Full table description: CREATE TABLE table_partition (...
2 votes
2 answers
118 views
Pros and cons of `INSERT INTO` versus `UNION ALL`
I am working with an Oracle database in which each year's data is stored in different tables. I am not the DBA so I cannot change that. Also, I do not have the permission to consult execution plans or ...
3 votes
0 answers
104 views
Azure Cosmos: MongoDB sharded cluster: $in query performance degrades with fewer values
I'm facing a counter-intuitive performance issue with my MongoDB sharded cluster where queries with fewer values in an $in clause are significantly slower than queries with more values. The Issue: ...
0 votes
3 answers
130 views
How to update by the other GROUPed table values effectively?
I have the tables Invoices (with No_ key) and the related InvoiceLines (with [Document No_] key that bounds to their invoices). The subset of invoice numbers is inserted into the table variable (no ...
-4 votes
1 answer
62 views
How to precompute nested date ranges efficiently to optimize range filtering and pagination? [closed]
📝 Body I have a Mongo collection CollectionA where each top-level object contains a nested array of meetings now each meetings have start and end times, for example: CollectionA = [ { &...
0 votes
1 answer
151 views
SQL query produced by Entity Framework very slow
I have the following query being generated by EF: DECLARE @__term_0 VARCHAR(7) = 'woodrow' DECLARE @__p_1 INT = 0 DECLARE @__p_2 INT = 15 SELECT [t].[Id], [t].[City], [t].[Contact], [t].[CreatedBy], [...
-1 votes
2 answers
236 views
Azure SQL S0 Tier – Slow Update Performance During Peak IoT Data Processing
I'm using Azure SQL (Standard S0: 10 DTUs) to store data from various IoT devices. Each IoT device sends messages to my Azure IoT Hub, which then triggers an Azure Function App. The Function App ...
0 votes
2 answers
222 views
Why correlated scalar is 10x times slower in MySQL comparing to PG
Let's create a table with 3000 rows create table tt(id int, txt text); insert into tt with recursive r(id) as (select 1 union all select id + 1 from r where id < 3e3) select id, concat('name', id) ...
3 votes
1 answer
203 views
Why does this query slow down this much over time
I'm testing with a very simple database queue to see how fast I can process it. At the moment without even doing anything else then just retrieving it from the queue. A simple CTE query selects one ...
4 votes
1 answer
173 views
Why does 'Index Seek' read 20 million rows for `select max(uk) from T where uk <= @x`?
In a table T with 20 million rows and a unique constraint on integer column uk, the following query induces SQL Server 2019 to perform a scan of all index entries instead of a single seek: select max(...
1 vote
1 answer
101 views
MySQL 8 runs very slow when including a NOT IN in the where clause
I have a website that displays on the main page the 12 latest uploads from the site's users. In that query, users can filter out uploads from certain other users (hence the NOT IN clause). Here is an ...