Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
Syndicate_Admin
Administrator
Administrator

SQL timeout problem

Good morning

I have a somewhat strange problem.
I have a database with a table of more than 30 million records.
If I import the data WITHOUT FILTERS the query has no error but takes longer to update. However, the strange thing is that if I filter the table to bring me only 2 million (which are what I need) the query throws me "timeout".

Doing some research I realized that it is VERY likely because of the conditions. That is, the SQL query with an extensive "WHERE" takes me longer than bringing me the whole table.
This is somewhat rare because a query without filters is supposed to take longer.

Is this okay or is there any possible error?

3 REPLIES 3
Syndicate_Admin
Administrator
Administrator

Thank you very much for the answers.
I'm almost sure it's because the tables don't have indexes.
In fact I have in the base the tables without indices that I throw a query and it generates a response quite fast, but if I execute it in a view it takes me much longer.
I'm almost sure it's because of the indices.

v-jianboli-msft
Community Support
Community Support

Hi @Syndicate_Admin ,

 

It's possible that the query with filters is taking longer due to the conditions in the "WHERE" clause. When you apply filters, the database engine needs to evaluate the conditions, which can sometimes be more time-consuming than fetching the entire table. This can happen if the conditions involve complex operations or if the database engine is unable to use indexes efficiently.

To improve the performance of your filtered query, you can try the following:

  1. Check if appropriate indexes are in place: Ensure that the columns used in the "WHERE" clause have proper indexes. This can help the database engine to quickly filter the records.

  2. Optimize the conditions: If the conditions in the "WHERE" clause involve complex operations, try to simplify them or break them down into smaller parts.

  3. Analyze the execution plan: Use tools like SQL Server Management Studio (SSMS) to analyze the execution plan of your query. This can help you identify bottlenecks and areas for optimization.

Remember that the performance of a query can be affected by various factors, such as the database engine, the structure of the table, and the available resources. It's essential to analyze the specific situation and make adjustments accordingly.

 

Best Regards,

Jianbo Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

lbendlin
Super User
Super User

This is standard behavior when your SQL Server table is missing indexes for your condition columns.  A table spool is always faster than a filtered query without indexes.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.