Skip to main content

Questions tagged [query-optimization]

For questions about making database queries run faster. PLEASE INCLUDE QUERY PLANS, AND TABLE AND INDEX DEFINITIONS in your question. Please use additional tags to specify your query language and server maker. Some of these questions may belong on https://DBA.stackexchange.com, especially if they involve reindexing, query plans, etc.

query-optimization
Filter by
Sorted by
Tagged with
3 votes
1 answer
105 views

I am working on a simple user defined function. It just accepts a varchar(100) parameter, does some string manipulation (nothing more complex than SUBSTRING, CHARINDEX, REPLACE etc. and returns a ...
Eric G's user avatar
  • 53
0 votes
0 answers
11 views

I am using Milvus to perform vector similarity search combined with a large ID-based filter, and I am concerned about query performance when the filter list becomes very large. My setup is as follows: ...
Veli Kıyak's user avatar
1 vote
0 answers
30 views

I have a BigQuery table (approx. 140 GB in size) that is synchronized from MongoDB via a Google Cloud Datastream. I have set the _id column as the clustering ...
Xiang Han's user avatar
3 votes
2 answers
74 views

I'm experiencing significant performance differences between two similar queries in MariaDB 10.4, and I'm looking for optimization suggestions. Problem Description I have three tables with similar ...
hyamanieu's user avatar
  • 1,145
Best practices
0 votes
15 replies
124 views

I have a T-SQL query shown here which is taking forever to run. I am trying to see if there is a better way to write the Inner Join statement. The source table has ...
Java's user avatar
  • 1,334
0 votes
1 answer
81 views

PostgreSQL tables sometimes store embeddings alongside relational columns and run vector similarity search with additional filters. Example schema ...
Abdul Bari's user avatar
Best practices
0 votes
3 replies
118 views

from a in xx join b in yy on a.someprop equals b.someprop join c in zz on a.someprop1 equals c.someprop where a.someprop2.Contains(strval) I’m trying to ...
chuackt's user avatar
  • 175
0 votes
2 answers
244 views

I'm experiencing a performance issue with the following query, specifically caused by the join condition AND edh.EmployeeCode = e.EmployeeCode After analyzing the ...
Akillez's user avatar
  • 17
3 votes
2 answers
156 views

There is a "theoretical" query: SELECT * FROM a JOIN ( SELECT b.pk, b.not_pk FROM b ORDER BY b.not_pk ) AS b2 USING (pk) and ...
Kuraga's user avatar
  • 435
0 votes
0 answers
81 views

I have a Table Valued Function (TVF) that takes an array of IDs as input. source_table: A very large table (TBs) partitioned by day on ...
Krishna Kashiv's user avatar
Tooling
0 votes
3 replies
63 views

I have a table-valued function (TVF) that takes an array of IDs as input. source_table: a very large table (TBs) partitioned by day on ...
Krishna Kashiv's user avatar
0 votes
0 answers
105 views

I'm using mongo db with payloadcms and I have tree like structure. We have a collection called nodes. A node have children as array and a parent id. Now I want to change the node status like marking ...
Shoaib Ahmed's user avatar
1 vote
1 answer
154 views

...
Thomas A Mathew's user avatar
3 votes
1 answer
119 views

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, ...
MatBailie's user avatar
  • 87.7k
1 vote
1 answer
70 views

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 ...
new coderrrr's user avatar
Advice
0 votes
6 replies
105 views

MariaDB version is 10.4.34. The query looks like: ...
catch32's user avatar
  • 18.8k
0 votes
1 answer
219 views

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: ...
Sergei Grigoriev's user avatar
2 votes
2 answers
142 views

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 ...
Thomas's user avatar
  • 553
3 votes
0 answers
134 views

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: ...
9308's user avatar
  • 31
0 votes
3 answers
136 views

I have the tables Invoices (with No_ key) and the related InvoiceLines (with ...
pepr's user avatar
  • 21.1k
-4 votes
1 answer
67 views

📝 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: ...
LEO_007's user avatar
  • 51
0 votes
1 answer
161 views

I have the following query being generated by EF: ...
TheIronCheek's user avatar
  • 1,241
-1 votes
2 answers
246 views

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 ...
DJDJ's user avatar
  • 763
0 votes
2 answers
225 views

Let's create a table with 3000 rows ...
Slimboy Fat's user avatar
3 votes
1 answer
208 views

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 ...
Hugo Delsing's user avatar
  • 14.3k
4 votes
1 answer
187 views

In a table T with 20 million rows and a unique constraint on integer column uk, the following query induces SQL Server 2019 to ...
DarthGizka's user avatar
  • 4,938
1 vote
1 answer
105 views

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 ...
Armitige3's user avatar
2 votes
2 answers
358 views

I recently came to know about the performance boosting capabilities of compound indexes or composite keys in ...
Mr.Singh's user avatar
  • 2,087
1 vote
0 answers
50 views

I want to query wikidata entities and their labels in multiple languages. But for some reason querying the labels is very inperformant. My base query looks like this (find 3 life forms that have ...
Kaligule's user avatar
  • 830
1 vote
1 answer
81 views

Attempting to optimize a portion of a query that is joining two related tables, and getting odd results compared to other queries in the project with similar structures. Here is a very simplified ...
jdfr228's user avatar
  • 11
3 votes
1 answer
127 views

I have a very large BigQuery table with web events that I want to aggregate into daily, weekly and monthly numbers of visitors. And I want to join them into the same table. My initial guess is to do ...
Jan Mulder's user avatar
2 votes
2 answers
162 views

I have the following query: ...
TheIronCheek's user avatar
  • 1,241
0 votes
1 answer
106 views

I have the below mentioned BigQuery SQL for a View. However, both the tables used in the query are huge in volume and hence I am facing terrible performance issues. If you'd glance at the query, I am ...
marie20's user avatar
  • 895
2 votes
2 answers
126 views

we have some tough performance issues that seem to us that they shouldn't exist, but we don't see any way of solving them. We have a Gcloud Mysql database, with 4Cpu, 16go Ram. The full instance ...
Jemox's user avatar
  • 304
5 votes
3 answers
119 views

It's very easy to see that BRIN indexes require orders of magnitude less space than BTREE indexes. However, I'm struggling to come up with a query where elapsed time with BRIN index vs BTREE index is ...
Slimboy Fat's user avatar
0 votes
1 answer
100 views

I’m troubleshooting slow queries on MySQL 8 and need advice. I have a table salla_events (~1M rows). The queries look like this: ...
medikbal's user avatar
2 votes
3 answers
234 views

I have a query which contains 3 tables. If the fetched data length is small (about 50,000) then it works very fast (nearly under a second), but when the data starts exceeding it becomes slower (9 ...
Mr.Singh's user avatar
  • 2,087
1 vote
3 answers
112 views

As an example, imagine I want to log the outside temperature in a table. It is read every minute but changes only 20 times a day or so, hence I don't want useless entries every minute. A value shall ...
Droidum's user avatar
  • 456
3 votes
1 answer
99 views

I have a TimescaleDB table that records activities of various devices. This is a huge table and any interactions with it are normally expensive. Devices can be enabled as a group, and activation has a ...
kaqqao's user avatar
  • 16.2k
2 votes
2 answers
128 views

I have the following table in my MySQL DB: ...
MM.'s user avatar
  • 77
-1 votes
1 answer
130 views

I have a SQL script that updates data in various tables. It used to run quickly but is now slowing down. The tables being updated have NVARCHAR(MAX) columns and ...
DrGriff's user avatar
  • 4,944
1 vote
3 answers
105 views

I have this index: ...
aikipooh's user avatar
  • 301
0 votes
1 answer
303 views

I am working in the backend of an application. One part of this application (like every application nowadays) is using AI for multiple things. The application's main purpose is building data warehouse ...
ne0123.'s user avatar
  • 23
4 votes
2 answers
179 views

I have a legacy Drupal 7 site that is used strictly internally. It's replacement is under active development, but in the meantime it is using Aurora2, MySQL 5.7 compatible and is in very expensive ...
greendemiurge's user avatar
0 votes
2 answers
186 views

I have a select with a large joined table. On local, performance is fine, but on my server it takes much longer. Below are the version infos (I just upgraded to MariaDB 11.4 on the server). If I do an ...
Philipp M's user avatar
  • 3,558
5 votes
4 answers
233 views

I have the tables "projects" (362K rows) and "projects_employees" (4.27M rows), one-to-many. I'm trying to get aggregated data for every employee and it takes 6-7 seconds. Is there ...
Victoria's user avatar
2 votes
2 answers
202 views

I am coming across a strange issue with EF Core 8.017. I have a query that searches a table of document metadata. A document's text is a column with a full text catalog that is queried using the ...
Donald Singer's user avatar
0 votes
1 answer
188 views

Table #1: buck number(10), sname varchar(20), ... total of 20 columns Table #2: ...
Dark3963's user avatar
2 votes
1 answer
35 views

I'm learning SQL optimization of deferred joins from this article(https://hackmysql.com/deferred-join-deep-dive/). The author uses a simple example to explain. Presume pk is the primary key column, ...
MeYokYang's user avatar
1 vote
1 answer
63 views

I have following schema.prisma generated from existing db structure: ...
Ludmila Kurochkina's user avatar

1
2 3 4 5
232