Nested set tables in select query "in the clause of" take long time

create or replace type t_circuitids is table of the varchar2 (100);

-Under anonymous block continues to run away and never ends

DECLARE
v_circuitid t_circuitids;
number of v_count;
l_circuitids VARCHAR2 (4000)
: = "Value1, value2, value3, value4, Value5";
BEGIN
-Query below converts the output concatinated with commas to the list and stores it in the nested table collection v_circuitids
WITH an ACE
(SELECT ',' | l_circuitids |) ',' AS circuitid
THE DOUBLE)
SELECT DISTINCT TRIM (SUBSTR (circuitid,
INSTR (circuitid, "," 1, LEVEL) + 1.
INSTR (circuitid, "," 1, LEVEL + 1)
-INSTR (circuitid, "," 1, LEVEL)
-1
)
) cid
LOOSE COLLECTION v_circuitid
A
CONNECT BY LEVEL <
LENGTH (circuitid)
-LENGTH (REPLACE (circuitid, ','));

SELECT COUNT (1)
IN v_count
TABLE
WHERE name IN (SELECT COLUMN_VALUE
TABLE (v_circuitid));
END;
/

-I had the question, query "SELECT COLUMN_VALUE FROM TABLE (v_circuitid)" that is used in code above is responsible for this.

-Same code works fine in development and Test environments, but prod it continues to work on

-I solved this problem by creating a temporary table, loading of all values in the collection in the temporary table and using this temporary table "in the clause" "

-Can answer why his behavior like this when I use the collection where clause?

-I use Oracle 9i

Here is a summary of the question and the solution for this.

-Nested type to collect multiple values

CREATE or REPLACE the TYPE t_circuitid IS TABLE OF VARCHAR2 (100);

Below the code will simply on the run.

DECLARE
v_circuitid t_circuitid;
v_count NUMBER;
BEGIN
SELECT nal_name
LOOSE COLLECTION v_circuitid
OF fs_head
WHERE groupid = 10;

SELECT COUNT (1)
IN v_count
OF fs_attrib
WHERE NAME IN (SELECT COLUMN_VALUE
TABLE (v_circuitid));

Dbms_output.put_line (v_count);
END;
/

Cause:-SELECT COLUMN_VALUE TABLE (v_circuitid)); -This request is causing problem

Why?  : - Because the CBO does not know how many lines is present in the collection, by default it takes 8168 lines

Note:-always happens, it depends on the volume of data in the table, the path chosen by CBO. In my case, the table is huge on prod compared to DEV so he was causing a problem.

-The following modified code works very well

DECLARE
v_circuitid t_circuitid;
v_count NUMBER;
BEGIN
SELECT nal_name
LOOSE COLLECTION v_circuitid
OF fs_head
WHERE groupid = 10;

SELECT COUNT (1)
IN v_count
OF fs_attrib
WHERE NAME IN (SELECT / * + cardinality (20 t) * /)
COLUMN_VALUE
TABLE (v_circuitid) t);

Dbms_output.put_line (v_count);
END;
/

Solution:-used as cardinality hint below.

SELECT / * + cardinality (20 t) * / t COLUMN_VALUE TABLE (v_circuitid);

Using cadinality I am saying CBO which dataset contains 20 lines or less.

If it is version of Oracle 10 g and more, we can use below code (CARD utility).

SELECT COLUMN_VALUE TABLE (CARD ((v_circuitid))

For more information reach me at [email protected]

Thank you best regards &,.

Amarnath a. Reddy.

Tags: Database

Similar Questions

  • It is good to turn on the printer for a long time?

    Hi all

    It is good to turn on the printer for a long time? It causes health and ink?
    Thank you

    Hi AhamedSajad,

    Are there specific that appeal to you?

    Turn on the printer for a long time would not adversely affect his health. Nor does it affect the ink somehow.
    The ink could get used only when you use the printer to print.
     
    I hope this helps.
  • Sinlge select query in the diff for the same table (same Structure) diagrams

    Scenario:

    Table XYZ is created in detail a.
    After a year, the old data of the previous year could be moved to another schema. However in the other schema of the same table name would be used.

    For example

    A schema contains XYZ table with data from the year 2012
    Schema B contains XYZ table with data for the year 2011
    Table XYZ in the two schemas have an identical structure.

    So we can draw a single select query to read the data from the tables in an effective way.
    For example select * from XYZ so including date between October 15, 2011 to March 15, 2012.
    However, the data resides in 2 different schema altogether.


    Creating a view is an option.
    But my problem, there are ORM (Hibernate or Eclipse Top Link) layer between the application and the database.
    If the queries would be constituted by the ORM layer and are not generated by hand.
    So I can't use the view.
    So is there any option that would allow me to use only query on different scheme?

    970773 wrote:
    Scenario:

    Table XYZ is created in detail a.
    After a year, the old data of the previous year could be moved to another schema. However in the other schema of the same table name would be used.

    For example

    A schema contains XYZ table with data from the year 2012
    Schema B contains XYZ table with data for the year 2011
    Table XYZ in the two schemas have an identical structure.

    So we can draw a single select query to read the data from the tables in an effective way.
    For example select * from XYZ so including date between October 15, 2011 to March 15, 2012.
    However, the data resides in 2 different schema altogether.

    Creating a view is an option.
    But my problem, there are ORM (Hibernate or Eclipse Top Link) layer between the application and the database.
    If the queries would be constituted by the ORM layer and are not generated by hand.
    So I can't use the view.

    Why not make the ORM as below?

    SELECT * FROM VIEW_BOTH;
    -VIEW_BOTH is a real VIEW of Oracle

  • How to store results of the select query in the tables.

    I created a variable varray type and now want to assign some data of output of the select query in pl/SQL, as well as in reports 6i.

    You are in the wrong forum (this is for problems with the SQL Developer tool). You were the one where you have published first on the right, but not to reuse independent threads as you did.

    Kind regards
    K.

  • attempts to cancel the query discoverer - it takes long time to cancel...

    Hello world

    I cancelled a beak of query. It took a long time to run

    Now it takes a long time to cancel

    The admin is out to lunch...

    all advice, pls, thx, sandra

    Hi, Sandra
    In general, the reason for the cancellation of a query is that it has worked too long - right?

    Behind the scenes, one of two things happening, either:

    1. the request was to have a hard time finding data and is always looking, or
    2. the query found some data but not enough to satisfy the query governor parameters

    For these, depending on the amount of data has so far been recovered, discoverer must these data somewhere. This is called a cache. The data you put in a cache more must be allowed to come out it should you decide not to go forward. This is probably what has happened to you.

    Also, when you cancel a query you are generally posed a question about whether discoverer must keep the last change but does not return any data. If you click Yes in response to this question is usually what triggers the compensation of the cache. Most of the time I just click No, even if I made a little change. I tend to get my quick return query.

    Finally, if your discoverer worksheet is a crosstab or use Page elements, or even both at the same time, it is one of the causes of a long-running query. In these scenarios, discoverer has buckets to calculate and he has no idea how many buckets to until he has read all the data.

    My Discoverer 10 g manual and in my training I speak on the motion of The Twilight Zone. These are queries than ever or never looks back all the data and either expire or must be stopped manually. Sometimes these runaway queries trying to return each row of data in the database, but more generally, they are caused by the use of overcasual of page elements or tables double entry.

    Let us hope that this logbook help
    Best wishes
    Michael

  • My Compaq presario must be connected to the network for a long time before it can start.

    It flashes green light and tyhen back when its ready flashing will stop. What is a power unit failure?

    Disconnect your PC from the network.

    There should be a switch on the power supply. See the image below. It is the red switch above the LED. You will need a flat head screwdriver to change its position.

    Leave the current (voltage) setting to the other setting and then drag it to the initial position (local network voltage). You have just reset your PSU with the procedure I described. If your PC is always the same question, then replace with a new PCU.

    Best regards
    ERICO

  • When I start the computer it takes more time

    * Original title: windows7 problem

    Sir I am on windows 7 ultimate. My problem is that when I star our sytem taking long time 6-7 minutes. Windows formats 3 - 4 times but still these problem and the functions are slow.what I...

    If after a reinstallation is complete, the computer is still slow, look to the material being the problem. The most likely cause is a failed hard drive.

    Hard drive utilities. You can test the drive with whchever is appropriate for your drive hard brand and model...

    Western Digital and Hitachi... http://support.wdc.com/product/download.asp?lang=en

    Samsung, Seagate and Maxtor... http://www.Seagate.com/support/downloads/

  • I used even to make the Blurays for a long time, with success, with no problems. Today, on my current project (.iso file estimated size ~ 19 GB) MENUS rendering time is reported as 31 + Hrs. Is this OK, or is there a problem?

    My system: 2013 Mac Pro: Core, 64 GB of Ram, two GPU of D700 12 / 3GB. I was creating an ISO image file using ENCORE 6. I am currently using the latest ADOBE CC system.

    The menu on which rendering takes a while has three normal buttons linking to 3 first videos produced. The menu has a long file AUDIO (about 90 minutes) as an attachment.

    After letting the rendering process to continue for 4 hours, on the audit of the progress window, progress bars seemed not to be ahead. I waited 2 + hours of overtime and checked again. Progress bars have been in the same place (no deposit). Activity monitor showed that still was still running. At this point, I cancelled the task. Then, I wanted to just MAKE THE MENUS. It is currently running for the 95 + last minutes. Details 'Render' reported ~29.5+ hours as TIME REMAINING. The number of processed IMAGES currently shows ~ 27000 + showing as 169065 in total. The meter for executives of the ongoing transformation to increment of the above stated figure of snapshot of 27000.

    I think that maybe I should let it continue to operate at the end (i.e. 30 hours of rendering time, if all goes well). Is - this sound NORMAL?

    Any advice will be appreciated.

    Never tried such an audio file for a long time. Are you sure that there is no video movement in this menu?

    What format is the audio file?

  • using multiple tables in a query in expdp clause

    Is it possible to use the table of multiples in a query of expdp option? I'm doing the following and it fails with the message 'Invalid identifier' I use Oracle version 10.2.0.3 10

    Settings (x.par)

    ************************

    DIRECTORY = DATA_PUMP_DIR

    USERID=XYZ/XYZ@DB1

    DUMPFILE = X.DMP

    LOGFILE = X.LOG

    CONTENT = DATA_ONLY

    TABLES = "TAB1".

    QUERY = TAB1: "WHERE EXISTS (SELECT 1 FROM TAB2 WHERE TAB2.)" KEYID = TAB1. KEYID).

    expdp parfile = x.par

    Error

    ******

    ORA-00904: "TAB1". "" KEYID ": invalid identifier

    Please share your ideas

    Thank you

    Great, thank you very much.it very really worked.

  • How can I set windows photo gallery to move the images one at a time as opposed to ten at a time?

    I have windows Vista on a HP HDX16 1140 - we... When I use windows photo gallery to view and touch up my photos, they move forward 10 pictures whenever I press a button, I want to change the setting in advance both to the next consecutive photo... How can I do this? Any help would be appreciated... I've had more trouble with Vista than any other OS.

    Thank you

    D Vera

    I don't remember see this posted question before.

    Just a wild guess... but maybe it's a mouse
    problem... try to advance your photos with your
    arrows right / left.

    It might be worth a try to
    Windows Live Photo Gallery.

    (FWIW... it's always a good idea to create a system)
    Restore point before installing software or updates)

    Windows Live Essentials: Photo Gallery
    http://explore.live.com/Windows-Live-Essentials-Photo-Gallery-get-started
    (There are other apps when you)
    install... uncheck those you don't want to)

  • I just bought the Officejet Pro 8600 more. The sprint is all set up. But it takes long time

    between the sending to print and actually printing the file. Is there a way to speed it up?

    The printer is now connected to the computer via a wireless connection. The scanner works fine and report may be the printer from the printer LCD display. After completing all of the proposed tests now the printer reacts much more quickly. Maybe it's because I turned off the printer and turn it back on and the printer has been reset correctly print wireless. Thanks for the help.

  • ORA-06502: PL/SQL: digital error or the value in the conversion for a long TIME on the CLOB type

    Hello

    I have an EA of RDBMS Oracle 11.2.0.4.

    I ger the following error when I try to convert a data type LONG to type CLOB data thanks to a PL/SQL procedure:

    declare
    v_prefix varchar2 (20): = null;
    v_text_view_clob clob: = null;
    long v_text_view_long: = null;

    cursor c_v
    is
    Select
    a.view_name as view_name
    Of
    USER_VIEWS one;

    Start
    for r_v in c_v
    loop
    Start
    v_text_view_clob: = null;
    v_text_view_long: = null;

    -Do the SQL code of the view
    Select
    a.Text text
    in
    v_text_view_long
    Of
    USER_VIEWS one
    where
    a.view_name = r_v.view_name;

    v_text_view_clob: = v_text_view_long;

    update of ohibo_views one
    set
    a.view_text = v_text_view_clob
    where
    a.view_name = r_v.view_name;
    exception
    while others then
    dbms_output.put_line ('View =' | r_v.view_name |) "kan niet worden geconverteerd!");
    dbms_output.put_line (substr (sqlerrm, 1, 60));
    end;
    end loop;
    -commit;
    exception
    while others then
    lift;
    end;
    /

    I get the error a specific record:

    View = VER_POLISMUTATIES_VW kan niet worden geconverteerd!

    ORA-06502: PL/SQL: digital error or value

    At looked the origina; Value of type LONG and it is indeed a "long" piece of text.

    However, CLOB has a restriction about 4G * db_block_size and LONG 2 G - 1 according to the documentation.

    I should be able with the method above to convert a LONG in CLOB.

    Anyone had a similar situation?

    Thanks in advance for advice how to solve.

    Kind regards

    PS: my apologies, I didn't know which group to post this discussion: database or PL/SQL.

    Good indeed, a link with the right explanation.

    I didn't know that there was such a function.

    Thank you!

    Kind regards

  • Purchase second stand-alone upgrade license LR6 not available in stores, is there a way for the user for a long time (since 1.0 more CC) to obtain a second license for both laptop and desktop?

    I've owned Lightroom since it was released when I paid $316,94 for her.  I bought the 2.0 for $103.95 update, then update 3.0 for $69.30 (on another account accidentally) and then joined the CC full suite.  Our Canadian dollar began to decline in value and I didn't feel that the subscription has been good value more, especially since I'm more a clean user of Photoshop and CS5.  I found that Lightroom is useful once again and so I bought last year updated for $88,48 USD and the product has glitches but I used it.

    Recently, I had to install on my Samsung laptop and found, I had to deactivate the license on my desk to use, and I find this pain connection and disconnection, since I do not have the foresight to know when to sign physically out of my office before I use my laptop.  Going to the Adobe store earlier, it does not allow me to buy another license upgrade for my second computer while the 'old' version of Lightroom was fine with me on my laptop and desktop.  I do not have a heavy user for a few years, but I start to have some interest in my work and need the laptop and the computer.  Adobe authorized a second upgrade license, am I expected to buy a full version new or I just go to Corel whose entire suite is less than the Lightroom upgrade?

    Again, I am mostly a Photoshop user and really need Lightroom to catalogue and cropping for final prints only selections, and it seems a little extreme that I cannot use my license on one computer at any time, why not the second?  I think Adobe is assuming we all have easy access to the internet and a wi - fi connection, and that Canadians want to pay twice as much for Adobe products as everyone else.  I installed two trials of Corel since they're cheaper reunited to form a new owner even a Lightroom update still less a total of the purchase, and so far they have integration with Photoshop and the feature settings of catalog, just I don't like not having to learn how to use when I already own another product.

    I'm moving this post on the forum of download, installation, commissioning , who can help with the perpetual software (not creative Cloud)

    It may be helpful to talk to sales http://www.adobe.com/about-adobe/contact.html

    or support: support (please login to adobe.com with your Adobe ID before clicking on the support)

  • I get this message when you try to start the firefox4 Script: chrome://tavgp/content/libs/include.js:595 and after clicking on ok, it takes long time for firefox open

    When I click on the firefox icon, the minutes pass and this is displayed: WARNING: unresponsive script: Script: chrome://tavgp/content/libs/include.js:595. iClick continue and again, after a minute or so firefox 4 starting ithen get a message: TypeError: components.classes['@ [cid] is undefined

    It is a problem with the AVG Safe Search toolbar.

    See:

  • not logged on as administrator won't let me connect to the internet for a long time

    My internet provider came home twice and said that its my comp. fault his so slow there or do not access whenever he said that when he sends a 100 files google thrgh he reads 49 errors. also, I was told that when I had Charter a diffrnt internet prvder then swtched to comcast, of that I have made a file that screws my internet I have no idea please help

    Go to the website of the manufacturer of your router > make sure you have the latest Firmware in Vista for it.

    Go to the website of the manufacturer of your computer/notebook > drivers and downloads Section > key in your model number > look for it last network adapters Vista drivers > download/install the.

    Try without commitment TCP/IPv6:

    If you still have internet connection probs, one thing to try is the separation of the TCP/IPv6 (which is done by going to network connection > right click > properties > it uncheck > OK.)

    http://digitalmediaphile.WordPress.com/IPv6-how-to-unbind-from-a-NIC-in-Windows-Vista/

    See you soon.

    Mick Murphy - Microsoft partner

Maybe you are looking for

  • Add a maximum of added following reverse order of selection 12.4

    In all cases if not see this? Select a few songs to add to the next game, they get added in the reverse order.  It worked the way we should expect 12.3. Play the next still work correctly; Add several song and added to until the next in their order i

  • Several Analyses in Terminal

    I run several analyses in Terminal (OSX 10.10.5; 8 GB RAM) and wonder how best to distribute my computing power. If I want to run 4 analyses, should I open 4 windows separated, or a window with 4 tabs? Also, can I know how much RAM / CPU is used by m

  • Pavilion g7: impossible to reinstall windows

    I tried to reinstall my OS (IE. Window 7 Ultimate 64-bit), before installation, everything was successful but when I tried to select the readers whose windows are primarily installation it says "not found Drivers? What kind of driver he asked? First

  • How can I Center the picture on my monitor?

    I'm not able to see my straight my screen thre controls. There is also a black band to the leftof the monitor. Please help me to position the image correctly. Thank you

  • HP Pavilion G6 1339SG: 1339SG HP Pavilion G6 - what the wifi card is compatible?

    Hello I recently posted my question on the German forum HP, but I'll do it here once more =) I bought the laptop next (A9Y86EA #ABD, System ID = 1670, BIOS = F.66). It has been installed a no compatible wifi card: AR5B95. According to the manual (htt