How to handle the slow query in SQL

As you find challenges in writing or maintaining database especially for SQL Server, here I found something that I either forget or don’t realise this.


Facing this query that always returning more than 1 minutes to run. I am checking about the index and I didn’t see anything significant.


When you join the table, ensure the data type between 2 tables are the same. In my case, I had fact table that has million of records and join with the reference table. One is using INT data type and the other one is using BIGINT data type. I’ve changed the reference one into INT instead.

Note: Pageviews – 3,396 (before migrated from Dewalist Blog website on 09/08/2020)