sql-execution-plan

Oracle Execution Plan

Deadly 提交于 2019-11-30 01:44:46
问题 I am using Oracle 11g and Toad for Oracle. How can I display execution plan for queries? In Sql server management studio execution plan can be displayed as graphical format. Is there any functionality/tool like that on Toad for oracle? 回答1: CTRL-E Make sure you've ended the query with a semi-colon (and the query above) Edit: You need to set-up the TOAD plan table for use. If you think it's already setup on your DB then you may just need to be granted access. Alternatively in my slightly older

How do I view the Explain Plan in Oracle Sql developer?

北城以北 提交于 2019-11-30 01:14:53
I have few SQL queries which has very low query running performance and I want to check the query execution plan for this query. I am trying to execute the below query but its not showing any query execution plan. Its only display message plan FOR succeeded. I dont know is there any settings that we have to do in oracle sql developer to vies explain plan for query : EXPLAIN PLAN FOR Select SO.P_OPTION_ID FROM SIMSIM JOIN P_TYPE PT on PT.KEY=SIM.P_TYPE_KEY JOIN P_CONFIG PC ON PC.ID=PT.PRODUCT_CONFIG_ID JOIN P_OPTION PO ON PO.OPTION_KEY=PC.DEFAULT_PRODUCT_OPTIONS JOIN S_OPTION SO ON SO.SERVICE

Why is this an Index Scan and not a Index Seek?

牧云@^-^@ 提交于 2019-11-30 00:29:53
Here's the query: SELECT top 100 a.LocationId, b.SearchQuery, b.SearchRank FROM dbo.Locations a INNER JOIN dbo.LocationCache b ON a.LocationId = b.LocationId WHERE a.CountryId = 2 AND a.Type = 7 Location Indexes: PK_Locations: LocationId IX_Locations_CountryId_Type: CountryId, Type LocationCache Indexes: PK_LocationCache: LocationId IX_LocationCache_LocationId_SearchQuery_SearchRank: LocationId, SearchQuery, SearchRank Execution Plan: So it's doing a Index Seek on Locations, using the covering index, cool. But why it is doing a Index Scan on the LocationCache covering index? That covering

SELECT TOP is slow, regardless of ORDER BY

[亡魂溺海] 提交于 2019-11-29 16:23:52
问题 I have a fairly complex query in SQL Server running against a view, in the form: SELECT * FROM myview, foo, bar WHERE shared=1 AND [joins and other stuff] ORDER BY sortcode; The query plan as shown above shows a Sort operation just before the final SELECT , which is what I would expect. There are only 35 matching records, and the query takes well under 2 seconds. But if I add TOP 30 , the query takes almost 3 minutes! Using SET ROWCOUNT is just as slow. Looking at the query plan, it now

Combining datasets with EXCEPT versus checking on IS NULL in a LEFT JOIN

我的梦境 提交于 2019-11-29 13:56:33
I'm currently working my way through the Microsoft SQL Server 2008 - Database Development (MCTS Exam 70-433) certification. In one of the earlier chapters on Combining Datasets , I came across the EXCEPT (and INTERSECT ) commands. One example shows how to use EXCEPT to get all values from one table that doesn't have a related value in a second table like this: SELECT EmployeeKey FROM DimEmployee EXCEPT SELECT EmployeeKey FROM FactResellerSales The EXCEPT command was new to me, but with what I knew before today I would still easily solve the problem using a LEFT JOIN and check for IS NULL on

SQL function very slow compared to query without function wrapper

半世苍凉 提交于 2019-11-29 13:31:39
I have this PostgreSQL 9.4 query that runs very fast (~12ms): SELECT auth_web_events.id, auth_web_events.time_stamp, auth_web_events.description, auth_web_events.origin, auth_user.email, customers.name, auth_web_events.client_ip FROM public.auth_web_events, public.auth_user, public.customers WHERE auth_web_events.user_id_fk = auth_user.id AND auth_user.customer_id_fk = customers.id AND auth_web_events.user_id_fk = 2 ORDER BY auth_web_events.id DESC; But if I embed it into a function, the query runs very slow through all data, seems that is running through every record, what am I missing?, I

SQL Server pick random (or first) value with aggregation

一个人想着一个人 提交于 2019-11-29 11:46:06
How can I get SQL Server to return the first value (any one, I don't care, it just needs to be fast) it comes across when aggregating? For example, let's say I have: ID Group 1 A 2 A 3 A 4 B 5 B and I need to get any one of the ID's for each group. I can do this as follows: Select max(id) ,group from Table group by group which returns ID Group 3 A 5 B That does the job, but it seems stupid to me to ask SQL Server to calculate the highest ID when all it really needs to do is to pick the first ID it comes across. Thanks PS - the fields are indexed, so maybe it doesn't really make a difference?

Bad optimization/planning on Postgres window-based queries (partition by(, group by?)) - 1000x speedup

假装没事ソ 提交于 2019-11-29 10:17:38
问题 We are running Postgres 9.3.5. (07/2014) We have quite some complex datawarehouse/reporting setup in place (ETL, materialized views, indexing, aggregations, analytical functions, ...). What I discovered right now may be difficult to implement in the optimizer (?), but it makes a huge difference in performance (only sample code with huge similarity to our query to reduce unnecessary complexity): create view foo as select sum(s.plan) over w_pyl as pyl_plan, -- money planned to spend in this pot

Entity Framework cached query plan performance degrades with different parameters

跟風遠走 提交于 2019-11-29 04:47:24
I have the following problem. Background I'm trying to implement an autocomplete selector with MVC3, EF4 and jquery over a table wit 4.5 million records. This is the table: CREATE TABLE [dbo].[CONSTA] ( [afpCUIT] nvarchar(11) COLLATE Modern_Spanish_CI_AS NOT NULL, [afpNombre] nvarchar(30) COLLATE Modern_Spanish_CI_AS NULL, [afpGanancias] varchar(2) COLLATE Modern_Spanish_CI_AS NULL, [afpIVA] varchar(2) COLLATE Modern_Spanish_CI_AS NULL, [afpMonot] varchar(2) COLLATE Modern_Spanish_CI_AS NULL, [afpIntSoc] varchar(1) COLLATE Modern_Spanish_CI_AS NULL, [afpEmpl] varchar(1) COLLATE Modern_Spanish

Do foreign key constraints influence query transformations in Oracle?

两盒软妹~` 提交于 2019-11-29 01:49:58
I have a situation like this: create table a( a_id number(38) not null, constraint pk_a primary key (id) ); create table b( a_id number(38) not null ); create index b_a_id_index on b(a_id); Now b.a_id is in fact meant to be a foreign key referencing a.a_id , but it isn't formally declared as such. Obviously, it should be for integrity reasons. But does a foreign key constraint also improve join performance in general or in specific cases? If yes, for what types of query transformations? Is there any relevant documentation about this topic? I'm using Oracle 11g (11.2.0.2.0) Yes, having foreign