sql-execution-plan

Why NonClustered index scan faster than Clustered Index scan?

自作多情 提交于 2019-12-14 01:42:22
问题 As I know, heap tables are tables without clustered index and has no physical order. I have a heap table "scan" with 120k rows and I am using this select: SELECT id FROM scan If I create a non-clustered index for the column "id", I get 223 physical reads . If I remove the non-clustered index and alter the table to make "id" my primary key (and so my clustered index), I get 515 physical reads . If the clustered index table is something like this picture: Why Clustered Index Scans workw like

Different Execution Plan for the same Stored Procedure

旧街凉风 提交于 2019-12-13 13:22:17
问题 We have a query that is taking around 5 sec on our production system, but on our mirror system (as identical as possible to production) and dev systems it takes under 1 second. We have checked out the query plans and we can see that they differ. Also from these plans we can see why one is taking longer than the other. The data, schame and servers are similar and the stored procedures identical. We know how to fix it by re-arranging the joins and adding hints, However at the moment it would be

Force hint to index from entity framework to SQL Server

大憨熊 提交于 2019-12-13 05:41:39
问题 I am calling SQL Server 10 from Entity Framework in C# and want to get a query hint into the request. The database has indexes which operated normally from SQL run in Management Studio, but when calling the command from C# using Entity Framework in Visual Studio, the query planner chooses a full scan when there is already an index. I am creating dynamic predicates to request data in the following form: data.attributeText = data.vegaDB.attributeText.AsExpandable().Where(parentPredicate.Compile

How to read Verbose Output from MongoDB-explain(1)

让人想犯罪 __ 提交于 2019-12-13 04:01:10
问题 I have the following query.explain(1)-Output. It is a verbose output and my question is how to read that. How is the order of the operations? Does it starts with GEO_NEAR_2DSPHERE or with LIMIT? What does the field advanced express? And most important, where is this documented? Could not find this in the mongoDB-manual :( Query: db.nodesWays.find( { geo:{ $nearSphere:{ $geometry:{ type: "Point", coordinates: [lon, lat] } } }, "amenity":"restaurant" }, {name:1} ).limit(10).explain(1) The

Actual execution plan not updated after change in Azure SQL Database stored procedure

ε祈祈猫儿з 提交于 2019-12-13 03:13:18
问题 The actual execution plan for my Azure SQL Database stored procedure indicated the following warning: So I went and added a persisted calculated column in dbo.Interest_rate_changes like this: [Effective_date] AS (CONVERT([date],CONVERT([nchar](8),[Effective_date_int]),(112))) PERSISTED NOT NULL I then replaced all references to Interest_date_int in the stored procedure with references to Interest_date. I ran the query again but the same warning appeared in the actual execution plan, even

DB2 LUW 10.5 - How to force DB2 Stored procedures to use latest stats for most optimized plan

久未见 提交于 2019-12-13 03:07:19
问题 We see an issue occasionally. Stored procedure running a SQL runs very slow. Same SQL when run from command line runs very fast. It seems stored procedure uses a different path. The workaround for us is to drop and recreate the procedure, after which it picks up the right plan. Is there a way to execute a stored procedure with an instruction to regenerate execution plan at run time, so as to get the best plan every time. 回答1: You probably don't want to recompile plans every time you call your

Query is extremely slow due to Lazy Index Spool

无人久伴 提交于 2019-12-13 02:59:49
问题 On a powerful machine the SQL Server query is running too slowly. In the execution plan I can see that most of the time spent goes to a "Lazy Index Spooling" process. In the query some aggregate functions are being used for calculation of values. How can I speed-up the query (machine resources are enough)? Thanks in advance. 来源: https://stackoverflow.com/questions/26314632/query-is-extremely-slow-due-to-lazy-index-spool

PostgreSQL function execution plan cache principle

非 Y 不嫁゛ 提交于 2019-12-13 02:59:07
问题 Say I have 2 functions using third one. Say function check_permission(user_id) is used by get_company(user_id) and get_location(user_id). How would execution plan cache work? I mean would it be making separate execution plans for check_permission and get_company functions or would it be one plan for get_company? There is a chance that execution plan will be more efficient if it is built for get_company and get_location individually even if they are both using check_permission function. 回答1:

SQL Server : delay before output (a print statement) is produced

陌路散爱 提交于 2019-12-13 02:36:02
问题 I may have a slight feeling as to what is going on, but I thought I'd ask to get confirmation, and potentially look at an alternative. As a slight background, I've written a C# application that is providing a small front end to a stored procedure. The procedure contains a number of temporary table inserts from other stored procedures (and one table valued udf), and some xml processing. In order to get a sense of how far along I am in the stored procedure, I'm subscribing to the InfoMessage

Apache Flink - enable join ordering

僤鯓⒐⒋嵵緔 提交于 2019-12-12 19:24:43
问题 I have noticed that Apache Flink does not optimise the order in which the tables are joined. At the moment, it keeps the user-specified join order (basically, it takes the the query literally). I suppose that Apache Calcite can optimise the order of joins but for some reason these rules are not in use in Apache Flink. If, for example, we have two tables ' R ' and ' S ' private val tableEnv: BatchTableEnvironment = TableEnvironment.getTableEnvironment(env) private val fileNumber = 1 tableEnv