As you find challenges in writing or maintaning 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 any thing 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.