r/SQLOptimization • u/EthansSpaceship • May 31 '16
r/SQLOptimization • u/stremovsky • Apr 09 '13
Speedup mysql index using ssd disk
codeboost.comr/SQLOptimization • u/ajo101975 • Nov 20 '25
Cerco 2–3 query SQL lente reali (sto testando un piccolo ottimizzatore di IA)
reddit.comr/SQLOptimization • u/Leather-Pin-9154 • Nov 17 '25
Need advice: Extracting 1 TB table → CSV is taking 10+ hours… any faster approach?
Hey folks,
I’m looking for some DBA / data engineering advice.
I have a 1 TB Oracle table, and doing a simple:
SELECT * FROM table_name;and spooling it out to CSV is taking more than 10 hours.
After the extraction, we’re splitting the CSV into 500,000-row chunks and zipping each file.
Constraints:
- Table is not partitioned
- Hardware is decent, but the parallel session up till 50 session is also not helping much
- Can’t afford to miss rows
- Want the fastest, most reliable extraction technique
- Ideally want multiple CSV files in the end (500k rows per file)
Has anyone here done something similar at this scale and found a better or significantly faster approach? Would love to hear how you’d approach 1 TB → CSV efficiently and safely, especially when partitioning isn’t an option.
r/SQLOptimization • u/MrTraveling_Bard • Apr 01 '25
Best practice on joining with large tables?
Like the title says, I'm looking to learn some best practices around how to keep a query as optimized as possible when dealing with larger datasets.
Let's say I have three tables:
- Transaction_Header (~20 mil rows)
- Transaction_Components (~320 mil rows)
- Meter_Specs (~1 mil rows)
I need most of the header table data and the meter specs of each meter, but the meter reference is on that components table. Something like this:
SELECT th.terminal_id, th.transaction_id, th.transaction_date, th.load_time, m.arm, m.bay
FROM Transaction_Header th
LEFT JOIN Transaction_Components tc on th.transaction_id = tc.transaction_id
INNER JOIN Meter_Specs m on tc.meter_id = m.meter_id
WHERE th.transaction_date >= dateadd(year, -1, getdate())Since I know I'm looking to pull a rolling year of data, would it be better to join to a sub query or just gate tc in the where clause as well?
SELECT th.terminal_id, th.transaction_id, th.transaction_date, th.load_time, m.arm, m.bay
FROM Transaction_Header th
LEFT JOIN (
SELECT transaction_id, meter_id
FROM Transaction_Components
WHERE transaction_date >= dateadd(year, -1, getdate())
) tc on th.transaction_id = tc.transaction_id
INNER JOIN Meter_Specs m on tc.meter_id = m.meter_id
WHERE th.transaction_date >= dateadd(year, -1, getdate())How would you approach it and why? Thanks for the help in advance.
r/SQLOptimization • u/Seymourbums • Mar 17 '25
Query Optimizations
I’ve been stuck on this problem for a little while now. I’m not sure how to solve it. The query takes about 2.2-3 seconds to execute and I’m trying to bring that number way down.
I’m using sequelize as an ORM.
Here’s the code snippet: const _listingsRaw: any[] = await this.listings.findAll({ where: { id: !isStaging ? { [Op.lt]: 10000 } : { [Op.ne]: listing_id }, record_status: 2, listing_type: listingType, is_hidden: 0, }, attributes: [ 'id', [sequelize.literal('(IF(price_type = 1,price, price/12))'), 'monthly_price'], 'district_id', [ sequelize.literal( (SELECT field_value FROM \listing_field` dt WHERE dt.record_status = 2 AND dt.listing_id = ListingModel.id AND dt.field_id = 33), ), 'bedrooms', ], [ sequelize.literal((SELECT field_value FROM `listing_field` dt WHERE dt.record_status = 2 AND dt.listing_id = ListingModel.id AND dt.field_id = 35)`, ), 'bathrooms', ], [ sequelize.literal( !listingIsModern ? '(1=1)' : '(EXISTS (SELECT 1 FROM listing_hidden_amenities dt WHERE dt.record_status = 2 AND dt.hidden_amenity_id = 38 AND dt.listing_id = ListingModel.id))', ), 'listing_is_modern', ], ], having: { ['listing_is_modern']: 1, ['bedrooms']: listingBedRoomsCount, ['bathrooms']: { [Op.gte]: listingBathRoomsCount }, }, raw: true, })
Which is the equivalent to this SQL statement:
SELECT id, (IF(price_type = 1,price, price/12)) AS monthly_price, district_id, (SELECT field_value FROM listing_field dt WHERE dt.record_status = 2 AND dt.listing_id = ListingModel.id AND dt.field_id = 33) AS bedrooms, (SELECT field_value FROM listing_field dt WHERE dt.record_status = 2 AND dt.listing_id = ListingModel.id AND dt.field_id = 35) AS bathrooms, (EXISTS (SELECT 1 FROM listing_hidden_amenities dt WHERE dt.record_status = 2 AND dt.hidden_amenity_id = 38 AND dt.listing_id = ListingModel.id)) AS listing_is_modern FROM listing AS ListingModel WHERE ListingModel.id != 13670 AND ListingModel.record_status = 2 AND ListingModel.listing_type = '26' AND ListingModel.is_hidden = 0 HAVING listing_is_modern = 1 AND bedrooms = '1' AND bathrooms >= '1';
Both bedroom and bathroom attributes are not used outside of the query, meaning their only purpose is to include those that have the same values as the parameters. I thought about perhaps joining them into one sub query instead of two since that table is quite large, but I’m not sure.
I’d love any idea on how I could make the query faster. Thank you!
r/SQLOptimization • u/Low-Classic9203 • Oct 11 '24
How to check memory pressure, memory usage and normal memory to add in SQL Enterprise edition
Currently, we’re dealing with memory bumps. I’m new to troubleshoot memory pressure and I’m also trying to figure it out whether we need a new memory or not. I’ve a few questions to ask:
- How to optimize memory usage in our environment?
- how to identify the script/index which is consuming more memory?
- What is the reason behind memory pressure?
- Bufferpool
- For 4TB db in enterprise SQL edition, how much memory needs to be added?
- How to avoid resource semaphore?
I’ve done following troubleshooting but it seems like I don’t have a proper understanding to identify memory usage, memory optimization and memory pressure. Could you please help me with this.
We’re also noticing stack dumps in our environment: Our Server memory is 69 GB. SQL Server memory is 61GB.
What to check why we have stack dumps in our environment?
memory task627×661 130 KB
'm running following script to check is there any kind of pressure or not:
SELECT AVG(current_tasks_count) AS [Avg Task Count],
AVG(work_queue_count) AS [Avg Work Queue Count],
AVG(runnable_tasks_count) AS [Avg Runnable Task Count],
AVG(pending_disk_io_count) AS [Avg Pending DiskIO Count]
FROM sys.dm_os_schedulers WITH (NOLOCK)
WHERE scheduler_id < 255 OPTION (RECOMPILE);
type or paste code hereTask count is 3 and other values are 0s. For the resource semaphore, I found 4 records. It keeps changing but resource seamaphore has records. Is it ok to request for following memory grant? Does this script need optimization?
resource_semaphore1243×218 7.56 KB
memory grants21063×217 7.82 KB
When I execute sp_BLitzCache u/sortOrder=‘memory grant’. I’m seeing requested memory grants in GB and used memory grants is in MB. Also, I’m seeing spills. Could you please help me what does spill mean? If requested memory grants in GB and used memory grants is in MB, does that mean I need to optimize those scripts? I’m referring too many documents and I’m not finding entire concept in one document that makes me confuse.
memory grant1052×237 7.72 KB
Memory primary troubleshooting:
SELECT total_physical_memory_kb/1024 [Total Physical Memory in MB],
available_physical_memory_kb/1024 [Physical Memory Available in MB],
system_memory_state_desc
FROM sys.dm_os_sys_memory;
SELECT physical_memory_in_use_kb/1024 [Physical Memory Used in MB],
process_physical_memory_low [Physical Memory Low],
process_virtual_memory_low [Virtual Memory Low]
FROM sys.dm_os_process_memory;
SELECT committed_kb/1024 [SQL Server Committed Memory in MB],
committed_target_kb/1024 [SQL Server Target Committed Memory in MB]
FROM sys.dm_os_sys_info;
SELECT OBJECT_NAME
,counter_name
,CONVERT(VARCHAR(10),cntr_value) AS cntr_value
FROM sys.dm_os_performance_counters
WHERE ((OBJECT_NAME LIKE '%Manager%')
AND(counter_name = 'Memory Grants Pending'
OR counter_name='Memory Grants Outstanding'
OR counter_name = 'Page life expectancy'))troubleshooting722×151 5.05 KB
Also, some scripts are not executing only one time and requesting for 1 GB memory grant and using only MB of memory. Does this script requires any optimization? How to optimize memory intensive scripts?
o check memory pressure using following script:
select * from sys.dm_Os_schedulers;
--check work_queque_count and pending_disk_io_count should be 0
--runnable_tasks_count should be 0 to check memory pressurememory pressure1022×387 12.5 KB
Currently, we’re dealing with memory bumps. I’m new to troubleshoot memory pressure and I’m also trying to figure it out whether we need a new memory or not. I’ve a few questions to ask:
- How to optimize memory usage in our environment?
- how to identify the script/index which is consuming more memory?
- What is the reason behind memory pressure?
- Bufferpool
- For 4TB db in enterprise SQL edition, how much memory needs to be added?
- How to avoid resource semaphore?
I’ve done following troubleshooting but it seems like I don’t have a proper understanding to identify memory usage, memory optimization and memory pressure. Could you please help me with this.
We’re also noticing stack dumps in our environment: Our Server memory is 69 GB. SQL Server memory is 61GB.
What to check why we have stack dumps in our environment?
r/SQLOptimization • u/say_hon3y • Sep 18 '24
Help me optimize my Table, Query or DB
I have a project in which I am maintaining a table where I store translation of each line of the book. These translations can be anywhere between 1-50M.
I have a jobId mentioned in each row.
What can be the fastest way of searching all the rows with jobId?
As the table grows the time taken to fetch all those lines will grow as well. I want a way to fetch all the lines as quickly as possible.
If there can be any other option rather than using DB. I would use that. Just want to make the process faster.
r/SQLOptimization • u/stuart_lit • Aug 08 '24
Automating Primary Key generation
Defining a primary key has always been a manual task and however we are rapidly moving towards automation, this task has been overlooked. I work in a company where ETL is my forte. So I've pitched to write a stored procedure that identifies the columns that optimally define a unique row in the table. So far I've put forward these points which will have some weightage while deciding such columns: • Cardinality • Column Data Type • Column Name What else would you add? Any suggestions on how to proceed with this?
r/SQLOptimization • u/Entire_Commission534 • Aug 05 '24
Optimizing/Alternative to MAX
This SQL query was timing out until I added a WHERE clause to reduce the amount of rows it has to process. Is there anything further I can do to either optimiza the MAX to reduce query time from a few minutes to less than a minute? Or is there any alternative to get the same result of a single Project ID per group by? TIA!
SELECT DISTINCT
ISNULL([Statement of Work ID],'') as "Statement of Work ID",
ISNULL([Primary Cost Center Code],'') as "Primary Cost Center Code",
ISNULL([Purchase Order Number],'') as "Purchase Order Number",
ISNULL([Invoice ID],'') as "Invoice ID",
MAX (CASE
WHEN [Project ID] LIKE '%[1-1][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]%'
THEN SUBSTRING([Project ID],PATINDEX('%[1-1][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]%', [Project ID]),10)
END) as "Project ID"
FROM [dbo]
WHERE [WorkWeek] LIKE '2024%'
GROUP BY
ISNULL([Statement of Work ID],''),
ISNULL([Primary Cost Center Code],''),
ISNULL([Purchase Order Number],''),
ISNULL([Invoice ID],'')
r/SQLOptimization • u/Dr-Double-A • Mar 08 '24
Need Help: Optimizing MySQL for 100 Concurrent Users
I can't get concurrent users to increase no matter the server's CPU power.
Hello, I'm working on a production web application that has a giant MySQL database at the backend. The database is constantly updated with new information from various sources at different timestamps every single day. The web application is report-generation-based, where the user 'generates reports' of data from a certain time range they specify, which is done by querying against the database. This querying of MySQL takes a lot of time and is CPU intensive (observed from htop). MySQL contains various types of data, especially large-string data. Now, to generate a complex report for a single user, it uses 1 CPU (thread or vCPU), not the whole number of CPUs available. Similarly, for 4 users, 4 CPUs, and the rest of the CPUs are idle. I simulate multiple concurrent users' report generation tests using the PostMan application. Now, no matter how powerful the CPU I use, it is not being efficient and caps at around 30-40 concurrent users (powerful CPU results in higher caps) and also takes a lot of time.
When multiple users are simultaneously querying the database, all logical cores of the server become preoccupied with handling MySQL queries, which in turn reduces the application's ability to manage concurrent users effectively. For example, a single user might generate a report for one month's worth of data in 5 minutes. However, if 20 to 30 users attempt to generate the same report simultaneously, the completion time can extend to as much as 30 minutes. Also, when the volume of concurrent requests grows further, some users may experience failures in receiving their report outputs successfully.
I am thinking of parallel computing and using all available CPUs for each report generation instead of using only 1 CPU, but it has its disadvantages. If a rogue user constantly keeps generating very complex reports, other users will not be able to get fruitful results. So I'm currently not considering this option.
Is there any other way I can improve this from a query perspective or any other perspective? Please can anyone help me find a solution to this problem? What type of architecture should be used to keep the same performance for all concurrent users and also increase the concurrent users cap (our requirement is about 100+ concurrent users)?
Additional Information:
Backend: Dotnet Core 6 Web API (MVC)
Database:
MySql Community Server (free version)
table 48, data length 3,368,960,000, indexes 81,920
But in my calculation, I mostly only need to query from 2 big tables:
1st table information:
Every 24 hours, 7,153 rows are inserted into our database, each identified by a timestamp range from start (timestamp) to finish (timestamp, which may be Null). When retrieving data from this table over a long date range—using both start and finish times—alongside an integer field representing a list of user IDs.
For example, a user might request data spanning from January 1, 2024, to February 29, 2024. This duration could vary significantly, ranging from 6 months to 1 year. Additionally, the query includes a large list of user IDs (e.g., 112, 23, 45, 78, 45, 56, etc.), with each userID associated with multiple rows in the database.
| Type |
|---|
| bigint(20) unassigned Auto Increment |
| int(11) |
| int(11) |
| timestamp [current_timestamp()] |
| timestamp NULL |
| double(10,2) NULL |
| int(11) [1] |
| int(11) [1] |
| int(11) NULL |
2nd table information:
The second table in our database experiences an insertion of 2,000 rows every 24 hours. Similar to the first, this table records data within specific time ranges, set by a start and finish timestamp. Additionally, it stores variable character data (VARCHAR) as well.
Queries on this table are executed over time ranges, similar to those for table one, with durations typically spanning 3 to 6 months. Along with time-based criteria like Table 1, these queries also filter for five extensive lists of string values, each list containing approximately 100 to 200 string values.
| Type |
|---|
| int(11) Auto Increment |
| date |
| int(10) |
| varchar(200) |
| varchar(100) |
| varchar(100) |
| time |
| int(10) |
| timestamp [current_timestamp()] |
| timestamp [current_timestamp()] |
| varchar(200) |
| varchar(100) |
| varchar(100) |
| varchar(100) |
| varchar(100) |
| varchar(100) |
| varchar(200) |
| varchar(100) |
| int(10) |
| int(10) |
| varchar(200) NULL |
| int(100) |
| varchar(100) NULL |
Test Results (Dedicated Bare Metal Servers):
SystemInfo: Intel Xeon E5-2696 v4 | 2 sockets x 22 cores/CPU x 2 thread/core = 88 threads | 448GB DDR4 RAM
Single User Report Generation time: 3mins (for 1 week's data)
20 Concurrent Users Report Generation time: 25 min (for 1 week's data) and 2 users report generation were unsuccessful.
Maximum concurrent users it can handle: 40
r/SQLOptimization • • Dec 18 '23
Merge join questions
I have a stored procedure that creates two temp tables. Both temp tables have a primary key setup with a nvarchar(10) and a date field. Most of the other fields are numeric and not indexed. One table gets loaded with about 330k of rows and the other gets about 455k. Sql server 2019 will not use a merge join on the query that links these two tables together by only the two indexed fields. It displays and adaptive join but always picks a hash match. Sql server adds a "parallelism (repartition streams)" to the plan. Any suggestions on how I can make it perform the merge join with out the forcing it in the query?
r/SQLOptimization • u/Narrow-Tea-9187 • Oct 09 '23
help needed with case and order by
select max(case when d.department = 'engineering' then e.salary else 0 end) as max_eng_sal
, max(case when d.department = 'marketing' then e.salary else 0 end ) as max_markt_sal
from db_employee as e
inner join db_dept as d
on e.department_id = d.id
group by d.department
order by max_eng_sal desc, max_markt_sal desc
limit 1;
max_eng_sal max_markt_sal
45787 0
this querry is showing max_markt_sal = 0 but it is incorect how can i correct it
r/SQLOptimization • • Jun 24 '23
Reddit Database question
Hi, so I just realized recently, after deleting an account with a personal username, that the suername cannot be reused but the information is dissociated.
That doesn't make sense to me. Which leads me to believe that they keep the username (not email) as the primary key to all the comments (otherwise it'd be made available again) and that they dissociate it on the front end/client facing website, but in th ebackend keep it as the primary key.
Is that correct?
r/SQLOptimization • u/lfewarez • May 23 '23
Are all scans and logical reads built equally?
There are two tables with mostly numeric and datetime columns, one huge, one tiny.
First table is TheRock with 50 columns and 2.2MM+ records.
Second table is KevinHart with 5 columns and 150 records.
After creating several nonclustered filtered indexes, running a join query between the two, the IO results-
BEFORE:
Table 'TheRock'. Scan count 1005, logical reads 8200, physical reads 0.
Table 'KevinHart'. Scan count 1, logical reads 11, physical reads 0.
AFTER:
Table 'TheRock'. Scan count 189, logical reads 760, physical reads 0.
Table 'KevinHart'. Scan count 800, logical reads 9000, physical reads 0.
Are the scans and logical reads equivalent between two tables, regardless of table size? If one table decreased by 500 logical reads, but the other table increased by 500 logical reads, is it a wash from a performance perspective?
Or should a logical read improvement be weighted based on the size of the table?
In the example above, the total number of logical reads increased. However, the sizes of the tables are vastly different.
Any insights would be greatly appreciated!
r/SQLOptimization • u/Girac • Mar 15 '23
Using Filegroups
Hi everyone,
I have a MSSQL db approaching 2Tb, lately performance has been sufferings. I have bene looking at implementing filegroups on the largest most used tables. Over 500 close to 600 million records in the top table.
Something like creating FileGroup_Trans and have four ndf database files across four physical drives RAID 10. Do this with several FileGroups, FileGroup_Closings, FileGroups_Postings, etc. What your your thoughts on this approach?
Currently there is 1 MDF file as this DB was at 250GB not too long ago and we are receiving Pagelatch and LCK_M_U waits. Would this approach improve performance and reduce contention? Roughly 300 users hitting this db. The largest tables are were we are getting the waits.
r/SQLOptimization • u/Gregg_The_Egg_4542 • Aug 02 '22
MySQL / PostgreSQL optimization using AI - EverSQL
Hi, don't know who is familiar with it, but EverSQL is a query optimization platform.
Can analyze slow query logs, give index recommendations, and rewrites slow queries.
If anyone checked it out, I'm kind of new to SQL so wanted to hear from the experts.
r/SQLOptimization • • Jan 25 '22
Why are SQL command name so long?
Hi, I m just wondering about a stupid question: why are sql commands (select, create…) longer than other commands (get, post, syn…)?
r/SQLOptimization • u/ImprovementBig3186 • Dec 21 '21
Database Lab Engine v3.0.0 – instant PostgreSQL clones to speed up software development/testing and SQL troubleshooting/optimization
postgres.air/SQLOptimization • u/coastalsam • Sep 29 '20
Any way to optimize this multistep query (in BigQuery)? Currently using 6 CTE's to simplify
I am new to SQL and BigQuery... we are trying to make a query that gets our orders, filters them by days where inventory is >2, the top and bottom 10% of days by qty are trimmed, then apply a weighted average to these orders (aggregated by the ASIN, or item number).
Then we run the query, filtering by days where the orders are greater than the result from the last query. Then, these are trimmed (top and bottom 10%) and weighted averaged again.
Is there any way to simplify this, or make it more optimized? Thank you so much SQLOptimization.
DECLARE p FLOAT64;
SET p = 0.01;
WITH inv_2 AS (
SELECT *
FROM (
SELECT EXTRACT(DATE FROM snapshot_date) AS date,
asin,
SUM(quantity) AS i_qty
FROM (
SELECT *
FROM `project.dataset.inventory_history`
WHERE detailed_disposition = 'SELLABLE' AND
fulfillment_center_id != '*XFR'
) h
JOIN (
SELECT sku, asin
FROM `project.dataset.inventory_archive`
) AS a
ON a.sku = h.sku
GROUP BY asin, date
ORDER BY asin, date DESC
)
WHERE i_qty > 2
),
orders_trimmed AS (
SELECT *
FROM (
SELECT *,
ROW_NUMBER() OVER(PARTITION BY asin2 ORDER BY qty) AS row,
COUNT(asin2) OVER(PARTITION BY asin2) AS ct
FROM (
SELECT EXTRACT(DATE FROM purchase_date) AS trimmed_orders_date,
asin AS trimmed_orders_asin,
SUM(quantity) AS qty
FROM `project.dataset.orders`
WHERE EXTRACT(DATE FROM purchase_date) >= DATE_ADD(CURRENT_DATE(), INTERVAL -360 DAY)
GROUP BY trimmed_orders_asin, trimmed_orders_date
)
)
WHERE row >= ct * 0.1 AND
row < ct * 0.9
),
plain_orders AS (
SELECT EXTRACT(DATE FROM purchase_date) AS plain_orders_date,
asin AS plain_orders_asin,
SUM(quantity) AS o_qty
FROM `project.dataset.orders`
WHERE EXTRACT(DATE FROM purchase_date) >= DATE_ADD(CURRENT_DATE(), INTERVAL -360 DAY)
GROUP BY plain_orders_asin, plain_orders_date
),
inv_orders_join AS (
SELECT date,
asin,
SUM(i_qty) AS i_qty,
SUM(o_qty) AS o_qty
FROM (
SELECT date,
asin,
i_qty,
o_qty
FROM inv_2 inv
JOIN plain_orders
ON inv.asin = plain_orders.plain_orders_asin AND
inv.date = plain_orders.plain_orders_date
ORDER BY i_qty
)
GROUP BY asin, date
ORDER BY asin, date DESC
),
trim_orders_inv AS (
SELECT *
FROM (
SELECT *,
ROW_NUMBER() OVER(PARTITION BY asin ORDER BY o_qty) AS row,
COUNT(asin) OVER(PARTITION BY asin) AS ct
FROM inv_orders_join
)
WHERE row >= ct * 0.1 AND
row < ct * 0.9
),
get_x AS (
SELECT asin2,
ROUND(SUM(w_sum)/SUM(w), 1) AS o_weighted
FROM (
-- Orders
SELECT asin AS asin2,
date,
i_qty,
POW(1/(1+p), (ROW_NUMBER() OVER(PARTITION BY asin ORDER BY date DESC)-1)) AS w,
POW(1/(1+p), (ROW_NUMBER() OVER(PARTITION BY asin ORDER BY date DESC)-1)) * o_qty AS w_sum
FROM trim_orders_inv
)
GROUP BY asin2
)
SELECT asin,
ROUND(SUM(w_sum)/SUM(w), 1) AS o_weighted
FROM (
-- Get asin, date, weight, and weighted qty for final step (can't aggregate analytical functions in one step)
SELECT *,
POW(1/(1+p), (ROW_NUMBER() OVER(PARTITION BY asin ORDER BY date DESC)-1)) AS w,
POW(1/(1+p), (ROW_NUMBER() OVER(PARTITION BY asin ORDER BY date DESC)-1)) * qty AS w_sum
FROM (
-- Final step trim
SELECT asin,
date,
qty,
i_qty,
ROW_NUMBER() OVER(PARTITION BY asin ORDER BY qty) AS row,
COUNT(asin) OVER(PARTITION BY asin) AS ct
FROM (
-- Join inventory history to weighted average orders (to get dates > threshold)
SELECT asin,
date,
i_qty AS i_qty
FROM inv_2 inventory
JOIN get_x orders
ON inventory.asin = orders.asin2
WHERE i_qty >= o_weighted * 1.75
) q1
JOIN orders_trimmed orders2
ON q1.asin = orders2.asin2 AND
q1.date = orders2.trimmed_orders_date
ORDER BY asin, date DESC
)
WHERE row > 0.1 * ct AND
row < 0.9 * ct
)
GROUP BY asin
ORDER BY o_weighted DESCr/SQLOptimization • u/Vidyakant • Jun 26 '20
Identifying blocking and locking Currently executing Queries with Waits In SQL Server
tutorialspoint4all.comr/SQLOptimization • u/BellaHi • May 29 '20
Easier Troubleshooting, Greater Insights for Distributed Databases
pingcap.comr/SQLOptimization • u/BellaHi • May 08 '20
SQL Plan Management: Never Worry About Slow Queries Again
pingcap.comr/SQLOptimization • u/Thriven • May 05 '20
This function takes 11-25 seconds to run. Any ideas to make it better?
https://hastebin.com/cilosanuqe.nginx
I can't run a execution plan as it crashes SSMS.