How the select Query Works
Hi All
I want to know how exactly the internal flow of select query works. Can someone please explain
Thanks
Hi,
Thanks for the link.Is there any example for back end process of Select queryBingo.. ;)
See, a process (or) set of programs which are working internally. You can get some of the results about the statistics of query how much cpu time it consuming, fetches etc., check v$sql_monitor. Apart from that if you are looking for some thing else then kindly elaborate your requirement.
- Pavan Kumar N
Similar Messages
-
How the below query is working
Hi,
I am newly joined in the group.
the emp table has 5 rows as below
100 ram 10000.00 10
200 kumar 15000.00 10
300 william 20000.00 10
400 ravi 25000.00 10
500 victor 30000.00 10
i execute the below query
select ename,sal from emp_test where case when sal < 10000 then sal + 1000
when sal < 20000 then sal + 2000
else sal
end < 20000
it gives the below output
ram 10000.00
kumar 15000.00
How the above query is working?
Please explain. thanks in advanceIf you want it to show the changed salary, it has to be in the select line not the where:
select ename,
(case when sal < 10000 then sal + 1000
when sal < 20000 then sal + 2000
else sal
end) sal from emp_test
where case when sal < 10000 then sal + 1000
when sal < 20000 then sal + 2000
else sal
end < 20000 -
How does the follwoing query work?
Want to know how does the follwoign query work??
For every row in flsp
the subquery is going to get executed or is it just one time execution of the subquery??
UPDATE flsp
SET (DURATION, sdr, inr) =
(SELECT SUM (tot_charges), SUM (tot_charges_sdr),
SUM (tot_duration)
FROM t
WHERE t.sender_pmn = flsp.sender_pmn
AND t.recipient_pmn = flsp.recipient_pmn
AND t.imsi_min = flsp.imsi
AND TRUNC (t.call_date) = TRUNC (flsp.call_date)
AND t.call_type = flsp.call_type
AND t.service_code = flsp.service_code
GROUP BY sender_pmn,
recipient_pmn,
imsi_min,
TRUNC (t.call_date),
call_type);
Edited by: user8731258 on Sep 27, 2010 2:54 AMuser8731258 wrote:
the global session table is going to hold data for one sessions where as the table flsp is going to hold data for the entire day.During a session there could be say 10 thousand records.Sounds like a bad idea.
user8731258 wrote:
ANd there are goign to aroung 100 such sessions.Continues to sound bad.
user8731258 wrote:
I have to update the flsp continually.Just got worse.
user8731258 wrote:
How do i make this fetch fast??This still makes no sense to me.
Why are you moving all this data around and utilizing temporary tables instead of directly querying the underlying data on an 'as needed' basis?
I think you have undertaken entirely the wrong technical approach to whatever business problem you are attempting to solve (though it's hard to say for sure as we still know little of what you've got going on).
So back to step number one like i asked before.
Can you explain (from the very beginning) WHY you are attempting this type of set up? -
How can i use index in select query.. facing problem with the select query.
Hi Friends,
I am facing a serious problem in one of the select query. It is taking a lot of time to fetch data in Production Scenario.
Here is the query:
SELECT * APPENDING CORRESPONDING FIELDS OF TABLE tbl_summary
FROM ztftelat LEFT JOIN ztfzberep
ON ztfzberep~gjahr = st_input-gjahr
AND ztfzberep~poper = st_input-poper
AND ztfzberepcntr = ztftelatrprctr
WHERE rldnr = c_telstra_accounting
AND rrcty = c_actual
AND rvers = c_ver_001
AND rbukrs = st_input-bukrs
AND racct = st_input-saknr
AND ryear = st_input-gjahr
And rzzlstar in r_lstar
AND rpmax = c_max_period.
There are 5 indices present for Table ZTFTELAT.
Indices of ZTFTELAT:
Name Description
0 Primary key( RCLNT,RLDNR,RRCTY,RVERS,RYEAR,ROBJNR,SOBJNR,RTCUR,RUNIT,DRCRK,RPMAX)
005 Profit (RCLNT,RPRCTR)
1 Ledger, company code, account (RLDNR,RBUKRS, RACCT)
2 Ledger, company code, cost center (RLDNR, RBUKRS,RCNTR)
3 Account, cost center (RACCT,RCNTR)
4 RCLNT/RLDNR/RRCTY/RVERS/RYEAR/RZZAUFNR
Z01 Activity Type, Account (RZZLSTAR,RACCT)
Z02 RYEAR-RBUKRS- RZZZBER-RLDNR
Can anyone help me out why it is taking so much time and how we can reduce it ? and also tell me if I want to use index number 1 then how can I use?
Thanks in advance.Hi Shiva,
I am using two more select queries with the same manner ....
here are the other two select query :
***************1************************
SELECT * APPENDING CORRESPONDING FIELDS OF TABLE tbl_summary
FROM ztftelpt LEFT JOIN ztfzberep
ON ztfzberep~gjahr = st_input-gjahr
AND ztfzberep~poper = st_input-poper
AND ztfzberepcntr = ztftelptrprctr
WHERE rldnr = c_telstra_projects
AND rrcty = c_actual
AND rvers = c_ver_001
AND rbukrs = st_input-bukrs
AND racct = st_input-saknr
AND ryear = st_input-gjahr
and rzzlstar in r_lstar
AND rpmax = c_max_period.
and the second one is
*************************2************************
SELECT * APPENDING CORRESPONDING FIELDS OF TABLE tbl_summary
FROM ztftelnt LEFT JOIN ztfzberep
ON ztfzberep~gjahr = st_input-gjahr
AND ztfzberep~poper = st_input-poper
AND ztfzberepcntr = ztftelntrprctr
WHERE rldnr = c_telstra_networks
AND rrcty = c_actual
AND rvers = c_ver_001
AND rbukrs = st_input-bukrs
AND racct = st_input-saknr
AND ryear = st_input-gjahr
and rzzlstar in r_lstar
AND rpmax = c_max_period.
for both the above table program is taking very less time .... although both the table used in above queries have similar amount of data. And i can not remove the APPENDING CORRESPONDING. because i have to append the data after fetching from the tables. if i will not use it will delete all the data fetched earlier.
Thanks on advanced......
Sourabh -
How to insert the select query result into table?
How to insert the select query result into table?
SELECT top 20 creation_time
,last_execution_time
,total_physical_reads
,total_logical_reads
,total_logical_writes
, execution_count
, total_worker_time
, total_elapsed_time
, total_elapsed_time / execution_count avg_elapsed_time
,SUBSTRING(st.text, (qs.statement_start_offset/2) + 1,
((CASE statement_end_offset
WHEN -1 THEN DATALENGTH(st.text)
ELSE qs.statement_end_offset END
- qs.statement_start_offset)/2) + 1) AS statement_text
FROM sys.dm_exec_query_stats AS qs
CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) st
ORDER BY total_elapsed_time / execution_count DESC;
Thanks,
Tirumala1. SELECT INTO
Below method will create table when data is inserted from one table to another table. Its useful when you need exactly same datatype as source table.
Use AdventureWorks2008R2;
Go
---Insert data using SELECT INTO
SELECT AddressLine1, City
INTO BothellAddresses
FROM Person.Address
where City = 'Bothell';
GO
---VERIFY DATA
Select AddressLine1, City
FROM BothellAddresses
---DROP TABLE
DROP TABLE BothellAddresses
GO
2. INSERT INTO SELECT
Below method will need table to be created prior to inserting data. Its really useful when table is already created and you want insert data from
another table.
Use AdventureWorks2008R2;
Go
---Create Table
CREATE TABLE BothellAddresses (AddressLine1 NVARCHAR(60), City NVARCHAR(30))
---Insert into above table using SELECT
INSERT INTO BothellAddresses(AddressLine1, City)
SELECT AddressLine1, City
FROM Person.Address
where City = 'Bothell';
---VERIFY DATA
Select AddressLine1, City
FROM BothellAddresses
---DROP TABLE
DROP TABLE BothellAddresses
GO
Regards,
Vishal Patel
Blog: http://vspatel.co.uk
Site: http://lehrity.com -
How to optimize the select query that is executed in a cursor for loop?
Hi Friends,
I have executed the code below and clocked the times for every line of the code using DBMS_PROFILER.
CREATE OR REPLACE PROCEDURE TEST
AS
p_file_id NUMBER := 151;
v_shipper_ind ah_item.shipper_ind%TYPE;
v_sales_reserve_ind ah_item.special_sales_reserve_ind%TYPE;
v_location_indicator ah_item.exe_location_ind%TYPE;
CURSOR activity_c
IS
SELECT *
FROM ah_activity_internal
WHERE status_id = 30
AND file_id = p_file_id;
BEGIN
DBMS_PROFILER.start_profiler ('TEST');
FOR rec IN activity_c
LOOP
SELECT DISTINCT shipper_ind, special_sales_reserve_ind, exe_location_ind
INTO v_shipper_ind, v_sales_reserve_ind, v_location_indicator
FROM ah_item --464000 rows in this table
WHERE item_id_edw IN (
SELECT item_id_edw
FROM ah_item_xref --700000 rows in this table
WHERE item_code_cust = rec.item_code_cust
AND facility_num IN (
SELECT facility_code
FROM ah_chain_div_facility --17 rows in this table
WHERE chain_id = ah_internal_data_pkg.get_chain_id (p_file_id)
AND div_id = (SELECT div_id
FROM ah_div --8 rows in this table
WHERE division = rec.division)));
END LOOP;
DBMS_PROFILER.stop_profiler;
EXCEPTION
WHEN NO_DATA_FOUND
THEN
NULL;
WHEN TOO_MANY_ROWS
THEN
NULL;
END TEST;The SELECT query inside the cursor FOR LOOP took 773 seconds.
I have tried using BULK COLLECT instead of cursor for loop but it did not help.
When I took out the select query separately and executed with a sample value then it gave the results in a flash of second.
All the tables have primary key indexes.
Any ideas what can be done to make this code perform better?
Thanks,
Raj.As suggested I'd try merging the queries into a single SQL. You could also rewrite your IN clauses as JOINs and see if that helps, e.g.
SELECT DISTINCT ai.shipper_ind, ai.special_sales_reserve_ind, ai.exe_location_ind
INTO v_shipper_ind, v_sales_reserve_ind, v_location_indicator
FROM ah_item ai, ah_item_xref aix, ah_chain_div_facility acdf, ah_div ad
WHERE ai.item_id_edw = aix.item_id_edw
AND aix.item_code_cust = rec.item_code_cust
AND aix.facility_num = acdf.facility_code
AND acdf.chain_id = ah_internal_data_pkg.get_chain_id (p_file_id)
AND acdf.div_id = ad.div_id
AND ad.division = rec.division;ALSO: You are calling ah_internal_data_pkg.get_chain_id (p_file_id) every time. Why not do it outside the loop and just use a variable in the inner query? That will prevent context switching and improve speed.
Edited by: Dave Hemming on Dec 3, 2008 9:34 AM -
Using case when statement in the select query to create physical table
Hello,
I have a requirement where in I have to execute a case when statement with a session variable while creating a physical table using a select query. let me explain with an example.
I have a physical table based on a select table with one column.
SELECT 'VALUEOF(NQ_SESSION.NAME_PARAMETER)' AS NAME_PARAMETER FROM DUAL. Let me call this table as the NAME_PARAMETER table.
I also have a customer table.
In my dashboard that has two pages, Page 1 contains a table with the customer table with column navigation to my second dashboard page.
In my second dashboard page I created a dashboard report based on NAME_PARAMETER table and a prompt based on customer table that sets the NAME_ PARAMETER request variable.
EXECUTION
When i click on a particular customer, the prompt sets the variable NAME_PARAMETER and the NAME_PARAMETER table shows the appropriate customer.
everything works as expected. YE!!
Now i created another table called NAME_PARAMETER1 with a little modification to the earlier table. the query is as follows.
SELECT CASE WHEN 'VALUEOF(NQ_SESSION.NAME_PARAMETER)'='Customer 1' THEN 'TEST_MART1' ELSE TEST_MART2' END AS NAME_PARAMETER
FROM DUAL
Now I pull in this table into the second dashboard page along with the NAME_PARAMETER table report.
surprisingly, NAME_PARAMETER table report executes as is, but the other report based on the NAME_PARAMETER1 table fails with the following error.
Error Codes: OPR4ONWY:U9IM8TAC:OI2DL65P
State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 16001] ODBC error state: S1000 code: 1756 message: [Oracle][ODBC][Ora]ORA-01756: quoted string not properly terminated. [nQSError: 16014] SQL statement preparation failed. (HY000)
SQL Issued: SET VARIABLE NAME_PARAMETER='Novartis';SELECT NAME_PARAMETER.NAME_PARAMETER saw_0 FROM POC_ONE_DOT_TWO ORDER BY saw_0
If anyone has any explanation to this error and how we can achieve the same, please help.
Thanks.Hello,
Updates :) sorry.. the error was a stupid one.. I resolved and I got stuck at my next step.
I am creating a physical table using a select query. But I am trying to obtain the name of the table dynamically.
Here is what I am trying to do. the select query of the physical table is as follows.
SELECT CUSTOMER_ID AS CUSTOMER_ID, CUSTOMER_NAME AS CUSTOMER_NAME FROM 'VALUEOF(NQ_SESSION.SCHEMA_NAME)'.CUSTOMER.
The idea behind this is to obtain the data from the same table from different schemas dynamically based on what a session variable. Please let me know if there is a way to achieve this, if not please let me know if this can be achieved in any other method in OBIEE.
Thanks. -
How the star schema works Make A Simple Query Show me the revenue for customers located in Sacramento for the Material Group Electronics in the month of October - Sequence the order of execution
a. Access the Fact Table
i. Select all the records in the Fact table which have meets the given criteria
b. Access the Dimension Table
i. Access the customer dimension table and select all the records with city =Sacramento
ii. Access the material dimension table and select all the records with Group =Electronics
iii. Access the Time dimension table and select all the records with Month =OctoberKutti,
Your explanation is in the opposite way -
access the Dimension tables and find the relevant DIM IDS for the given conditions --> search for the DIM IDs in the fact ...
You cannot hit the fact directly since the DIM IDs will not be the same as SIDs unless you are talking about line item dimensions...
best way is to have a query on a cube - execute it through RSRT and in the execute and debug option - select "Display SQL Query" and there you can see the query being run..
Arun
Assign points if useful -
Need some help with the Select query.
Need some help with the Select query.
I had created a Z table with the following fields :
ZADS :
MANDT
VKORG
ABGRU.
I had written a select query as below :
select single vkorg abgru from ZADS into it_rej.
IT_REJ is a Work area:
DATA : BEGIN OF IT_REJ,
VKORG TYPE VBAK-VKORG,
ABGRU TYPE VBAP-ABGRU,
END OF IT_REJ.
This is causing performance issue. They are asking me to include the where condition for this select query.
What should be my select query here?
Please suggest....
Any suggestion will be apprecaiated!
Regards,
DeveloperHello Everybody!
Thank you for all your response!
I had changes this work area into Internal table and changed the select query. PLease let me know if this causes any performance issues?
I had created a Z table with the following fields :
ZADS :
MANDT
VKORG
ABGRU.
I had written a select query as below :
I had removed the select single and insted of using the Structure it_rej, I had changed it into Internal table
select vkorg abgru from ZADS into it_rej.
Earlier :
IT_REJ is a Work area:
DATA : BEGIN OF IT_REJ,
VKORG TYPE VBAK-VKORG,
ABGRU TYPE VBAP-ABGRU,
END OF IT_REJ.
Now :
DATA : BEGIN OF IT_REJ occurs 0,
VKORG TYPE VBAK-VKORG,
ABGRU TYPE VBAP-ABGRU,
END OF IT_REJ.
I guess this will fix the issue correct?
PLease suggest!
Regards,
Developer. -
does anyone know how the cutout filter works and is there a way of achieving the same effect without using filters to get more control over final look?
Several ways to get similar results. Image > Adjustments > Posturize with low values similar to what you'd use n Cutout. This is the most flexible way I can think of as you keep the image in RGB mode with layers intact. A more radical approach would be to reduce bit depth using Indexed Colour. You'll need to experiment with settings, try changing Forced to Primaries, and Matte to Foreground Color. There's no going back from this route, although you can change the mode back to RGB to re-enable layers, adjustment layers etc.
A nice thing about the Filter gallery filters is that you can change the layer to a Smart object with all the control that gives you.
Now if only this forum could filter out bizarre content. -
I have an iPad 3.
I tried two, One was a worthless piece of junk I wasted $2.99 on and the other is pretty good ($1.99) except is does not do a function I would like to use as advertised ( which is to create a sticking note that works like an app by creating an icon sized version of the original created sticky note, then clicking on an app icon size version of the originally created sticky note that you can tap on like an app and a large sticky note is supposed to appear. This does NOT work with an iPad.
Does anyone use a Stickies app for IOS that works exactly like how the Stickies app works on a Mac?
What good is a Stickies note app on iOS when it cannot put actual virtual stickies notes over the main IOS screens and wallpapers and remain there until they are no longer needed?
Does any one use a good stickies app on iPad? NOT iPhone or iPod Touch.It really cannot be done in iOS due to the sandboxed security model of the operating system. No app can modify the "desktop" like that - they can only display their own "virtual" desktop when actually actively in use. so any stickie note app is the same as any simple note app - it must be open and active to display content. It cannot modify any screen but it's own when active.
-
Problem in the "select" query....Just check out and help me
Hi there !!
I am getting the following errors while trying to execute the "select" query from JSP page:
java.sql.SQLException: [Microsoft][ODBC Driver Manager] Invalid cursor state
My code is :
String reg_no=(String)session.getAttribute("reg_no");
ResultSet rs=stmt.executeQuery("SELECT * FROM reg WHERE regno = "+reg_no);
(Note: the "regno" in the database is of numeric datatype)
Try to help me...
Thanx,
Ram.Just so everyone knows:
Ram Mohan joined the forum on 7-Sep-2003 and received
his 25 Dukes for joining.
Since then, he's posted three questions, each one
promising 5-10 Dukes, and never once awarded them.
His strategy seems to be to wave Dukes, ask his
hit-and-run question, and then bolt.
Answer his questions if you wish, but don't do it
expecting Dukes. - MODDuffy, you're getting just as cranky as I have. See what hanging around these forums does to oneself? :) -
Restricting record in the select query
Is there any way to restrict the number of search (e.g 10) records in the SELECT query ?
Hi,
You can use as below:
select <fieldname> up to 10 rows from <tablename> into itab.
Thanks,
Sriram Ponna. -
How the PS Capex works in SAP R/3 Finance
Hi All,
how the secondary cost element is used in SAP for PS capex settlement ..
how the PS Capex works in SAP R/3 Finance
when the secondary cost elements starting with 9 and PS will accoounted in PS Capex Settlement
will the sencondary cost element be zero with regarding to PS Capex settlement postings.
Thanks & Regards
Nandhafor ECCN numbers we did a LSMW or you can do a BDC program
-
How the cache.invoke() works?
Hi, I am trying to play with the coherence 3.4.2 to find out how the cache.invoke() works. I modified the SimpleCacheExplorer.java coming as the example code as following:
1) I defined a distributed cache as following:
<?xml version="1.0"?>
<!DOCTYPE cache-config SYSTEM "cache-config.dtd">
<cache-config>
<caching-scheme-mapping>
<!--
Caches with any name will be created as default replicated.
-->
<cache-mapping>
<cache-name>*</cache-name>
<scheme-name>default-dist</scheme-name>
</cache-mapping>
</caching-scheme-mapping>
<caching-schemes>
<!--
Default Replicated caching scheme.
-->
<distributed-scheme>
<scheme-name>default-dist</scheme-name>
<service-name>DistributedCache</service-name>
<backing-map-scheme>
<class-scheme>
<scheme-ref>default-backing-map</scheme-ref>
</class-scheme>
</backing-map-scheme>
</distributed-scheme>
<!--
Default backing map scheme definition used by all
The caches that do not require any eviction policies
-->
<class-scheme>
<scheme-name>default-backing-map</scheme-name>
<class-name>com.tangosol.util.SafeHashMap</class-name>
</class-scheme>
</caching-schemes>
</cache-config>
2) I modified the SimpleCacheExplorer.java as following:
class MyProcessor extends com.tangosol.util.processor.AbstractProcessor
private static final long serialVersionURD = 8004040647128795431L;
private String cacheName = null;
public MyProcessor(String cacheName)
this.cacheName = cacheName;
public Object process(Entry entry)
NamedCache cache = CacheFactory.getCache(cacheName);
cache.clear();
return null;
public class SimpleCacheExplorer {
* Entry point.
* @param asArg command line arguments
public static void main(String[] asArg)
throws Exception
NamedCache cache = CacheFactory.getCache("Test");
cache.put("1", "one");
cache.invoke("1", new MyProcessor("Test"));
System.out.println("cache size = " + cache.size());
3) Then I got the following exception:
com.tangosol.util.AssertionException: poll() is a blocking call and cannot be called on the Service thread
Is there a way I can do the cache clear in the invocation way?
ThanksThe EntryProcessors operate against a particular Entry and usually executes on the node where the entry is stored. What you can do is to remove the particular entry this entryprocessor is aimed at by calling entry.remove()
Here is a modified entry processor that removes an entry.
class MyProcessor extends com.tangosol.util.processor.AbstractProcessor
private static final long serialVersionURD = 8004040647128795431L;
public MyProcessor() {}
public Object process(Entry entry)
if (entry.isPresent())
entry.remove(false);
return null;
}Getting a hold of the CacheFactory while executing an EntryProcessor is a re-entrant call in to the DistributedCacheService which is rendering the exception.
More on re-entrancy restrictions and recommendations in this whitepaper: [Coherence Planning: From Proof of Concept to Production|http://www.oracle.com/technology/products/coherence/pdf/Oracle_Coherence_Planning_WP.pdf]
Maybe you are looking for
-
I cant view my site in safari... hmmmmm
i forwarded my own domain to mask the url for my mac.web.com.yadda yadda yadda. i forwarded the frame to web.mac.com/myusername it took hours and it is finally working though my domain co said they didnt think it would. anyways.. it loads great on fi
-
Hi just wondering if anyone has a change in there order status yet. My details: Estimated Shipping: 13 Aug, 2010 Estimated Delivery: 20 Aug, 2010 Ordered: Jul 23, 2010 at 07:37 PM Any ideas on when mine will get shipped? Thanks, - Jahid
-
Clone tool has stopped working properly, the sample area doesn't follow the target area?
Clone tool has stopped working properly, the sample area doesn't follow the target area?
-
Saving to .png strips metadata
In Photoshop CS6, when you save an open file to .psd, .tif, or .jpg, whatever metadata it contains is saved with the file, and you can examine it in Bridge. But when you save to .png, the metadata panel in Bridge is empty - there's nothing there! Is
-
Hi. Downloaded ClassicToy app for free. Purchased the premium package worth $1.99 and got an email confirmation for a successful transaction but app has not been upgraded to premium package yet. Please help. Thanks