TLDR: I want to get a table with the previous two months in Teradata, based on CURRENT_DATE. Currently I can only get the previous month: Expected output is: Long version: I want something, that could be used in a bigger query like this, valid for every day of the year, without hardcoding the dates. The bigger query with the hardcoded
Tag: performance
What is the best solution for adding INDEX to speed up the query?
Now I have a Query that runs 50 minutes on Mysql database and I can’t accept that… I want this process can running under 15 minutes…. The “sourcetableid” and “mstid” are unique. So what is the best way to add INDEX or optimize on this? Thank you Answer I would write the select as: Then you want an index on
SQL Server performance optimization
I have table to store files. I store SHA256 hash in a column to uniquely identify a file. Before inserting new file I check for duplicate file using the hash and if it exists already I don’t insert. For example my query can be: Right now there are only a few hundred files. When this number grows to a few
High performance query to get datetime when value was last changed
The data I am working with Consider the following 2 database tables: CREATE TABLE [dbo].[Contact]( [ID] [int] IDENTITY(1,1) NOT NULL, [Contact_UID] [uniqueidentifier] NOT NULL CONSTRAINT […
How can I optimise COUNT with GROUPBY mysql query?
I have 5M records in eus table and 121 records in es table. I am doing a left join but the COUNT query is making my query very slow. How can I optimize this? public static function …
SQL query – Records has at least one of the relationships specified – alternative?
I have 4 tables person, employments, properties, memberships How can I filter people that have at least one of the three relationships above? What I tried: Seems to be working, but it looks odd, and I am not sure if it’s the most efficient way of doing it. Any tips? Answer Your IN clauses are redundant. You have a correlation
Is there a way to change this BigQuery self-join to use a window function?
Let’s say I have a BigQuery table “events” (in reality this is a slow sub-query) that stores the count of events per day, by event type. There are many types of events and most of them don’t occur on …
SQL: Nested Select vs Double JOIN by Performance
I have report based on a stored procedures and I need to add User name into output. In my system TWO users can be owners of transaction. Also, in my system User information stored in different …
SQL View slow when filtered. Is there a clean way to improve performance?
Let me open with: SHOWPLAN permission denied in database ‘MyDatabase’. With that out of the way, I’ll layout my situation. So, The database I work with has a view that executes fairly quickly. …
SELECT COUNT with JOIN optimization for tables with > 100M rows
I have following query SELECT SUBSTRING(a0_.created_date FROM 1 FOR 10) AS sclr_0, COUNT(1) AS sclr_1 FROM applications a0_ INNER JOIN package_codes p1_ ON a0_.id = p1_.application_id …