Performance ... normal selects and the same selects in functions
Hi there,
hope you guys can help me a little.
We use a bunch of dictionary tables to map certain values to IDs. In the "real" data tables we save the IDs instead of the values themselves.
Those tables are usually pretty small.
Normally we would join these tables into our selects, such as this:
select ...
from data_table d,
lookup_table l
where d.l_id=l.id
But we also got some functions we use to lookup these values to have simple selects:
select ..., my_function(l_id)
from data_table
Or for reverse lookup:
select ...
from data_table
where l_id=my_function(l_id)
Do you know, if smaller selects capsuled in functions are more or less performant then simply joining these tables into the big selects?
Sometimes we also use small statements on large tables (4.000.000 records) ... sometimes we use them in functions as well ...
select bla
from large_table
where id=...
Thanks for your hints,
Steff
How you did your tests?
A short conclusion of test below:
I've created 2 tables one base table and one lookup table.
Then created function to get lookup value from lookup table.
then run select to get all lookup values from base table using join and using function.
Join needed 0.01 sec, function needed at least 2.08 secs.
Then I've created an anonymous script to loop through all base values and get aproprite lookup values using function and using join and compared results using runstats.
As a result join performed at more than 2 times faster and required more than 2 times less latches.
and here is the listing
SQL> create table lookup_table (
2 lkp_id number not null,
3 lkp_val varchar2(10) not null);
Table created.
Elapsed: 00:00:00.00
SQL> alter table lookup_table add constraint lkp_pk primary key (lkp_id);
Table altered.
Elapsed: 00:00:00.00
SQL>
SQL> insert into lookup_table select rownum, substr(object_name, 1, 10) from dba_objects;
42221 rows created.
Elapsed: 00:00:00.05
SQL> create or replace function get_lkp_value (in_id number) return varchar2
2 is
3 ret lookup_table.lkp_val%TYPE;
4 begin
5 select lkp_val into ret from lookup_table where lkp_id = in_id;
6 return ret;
7 end;
8 /
Function created.
Elapsed: 00:00:00.01
SQL> create table base_table (
2 bas_id number not null,
3 bas_lkp_id number not null,
4 bas_data varchar2(1000) not null);
Table created.
Elapsed: 00:00:00.00
SQL>
SQL> insert into base_table select rownum, rownum, object_name
2 from dba_objects where rownum <= 42221;
42221 rows created.
Elapsed: 00:00:00.05
SQL> alter table base_table add constraint bas_pk primary key (bas_id);
Table altered.
Elapsed: 00:00:00.02
SQL> alter table base_table add constraint bas_lkp_fk foreign key (bas_lkp_id)
2 references lookup_table (lkp_id);
Table altered.
Elapsed: 00:00:00.01
SQL> create index bas_lkp_idx on base_table (bas_lkp_id);
Index created.
Elapsed: 00:00:00.02
SQL> exec dbms_stats.gather_table_stats(user, 'lookup_table');
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.01
SQL> exec dbms_stats.gather_table_stats(user, 'base_table');
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.02
SQL> select count(distinct lkp_val) from (
2 select bas_id, bas_data, get_lkp_value(bas_lkp_id) lkp_val
3 from base_table);
COUNT(DISTINCTLKP_VAL)
13622
Elapsed: 00:00:03.01
SQL> /
COUNT(DISTINCTLKP_VAL)
13622
Elapsed: 00:00:02.08
SQL> /
COUNT(DISTINCTLKP_VAL)
13622
Elapsed: 00:00:03.01
SQL> select count(distinct lkp_val) from (
2 select bas_id, bas_data, lkp_val
3 from base_table, lookup_table
4 where bas_lkp_id = lkp_id);
COUNT(DISTINCTLKP_VAL)
13622
Elapsed: 00:00:00.01
SQL> /
COUNT(DISTINCTLKP_VAL)
13622
Elapsed: 00:00:00.01
SQL> ed
Wrote file afiedt.buf
1 declare
2 cursor c1 (in_id in number) is
3 select bas_id, bas_data, lkp_val
4 from base_table, lookup_table
5 where bas_lkp_id = lkp_id
6 and bas_id = in_id;
7 val1 c1%ROWTYPE;
8 cursor c2 (in_id in number) is
9 select bas_id, bas_data, get_lkp_value(bas_lkp_id)
10 from base_table
11 where bas_id = in_id;
12 val2 c2%ROWTYPE;
13 begin
14 runstats_pkg.rs_start;
15 for i in 1..42220 loop
16 open c1(i);
17 fetch c1 into val1;
18 close c1;
19 end loop;
20 runstats_pkg.rs_middle;
21 for i in 1..42220 loop
22 open c2(i);
23 fetch c2 into val1;
24 close c2;
25 end loop;
26 runstats_pkg.rs_stop;
27* end;
SQL> /
Run1 ran in 390 hsecs
Run2 ran in 910 hsecs
run 1 ran in 42,86% of the time
Name Run1 Run2 Diff
LATCH.kwqit: protect wakeup ti 0 1 1
LATCH.spilled msgs queues list 0 1 1
STAT...change write time 0 1 1
LATCH.active checkpoint queue 1 3 2
LATCH.cache buffer handles 24 26 2
LATCH.process allocation 0 2 2
STAT...cleanout - number of kt 3 5 2
STAT...consistent gets - exami 253,323 253,325 2
STAT...consistent gets 253,323 253,325 2
STAT...calls to kcmgcs 3 5 2
STAT...active txn count during 3 5 2
LATCH.session timer 1 3 2
LATCH.event group latch 0 2 2
LATCH.channel handle pool latc 0 4 4
LATCH.transaction allocation 0 4 4
STAT...db block gets 520 524 4
LATCH.list of block allocation 0 4 4
LATCH.process group creation 0 4 4
LATCH.dummy allocation 0 4 4
LATCH.post/wait queue 11 16 5
LATCH.Consistent RBA 18 24 6
LATCH.mostly latch-free SCN 18 24 6
STAT...consistent changes 510 516 6
STAT...session logical reads 253,843 253,849 6
STAT...db block changes 1,020 1,026 6
LATCH.lgwr LWN SCN 18 24 6
LATCH.channel operations paren 4 12 8
LATCH.user lock 0 8 8
LATCH.simulator lru latch 13 2 -11
LATCH.sequence cache 56 71 15
LATCH.redo writing 59 82 23
LATCH.enqueues 30 60 30
STAT...hot buffers moved to he 31 0 -31
LATCH.messages 100 149 49
LATCH.cache buffers lru chain 91 33 -58
LATCH.session idle bit 230 290 60
LATCH.SQL memory manager worka 136 223 87
STAT...free buffer requested 91 4 -87
STAT...shared hash latch upgra 87 0 -87
STAT...physical reads 87 0 -87
LATCH.checkpoint queue latch 69 181 112
LATCH.session allocation 44 178 134
LATCH.redo allocation 622 819 197
LATCH.undo global data 61 263 202
LATCH.dml lock allocation 92 312 220
LATCH.row cache enqueue latch 356 580 224
LATCH.simulator hash latch 12,430 12,204 -226
LATCH.row cache objects 360 626 266
LATCH.enqueue hash chains 141 477 336
STAT...recursive cpu usage 259 596 337
STAT...Elapsed Time 392 913 521
LATCH.library cache pin alloca 402 1,100 698
LATCH.cache buffers chains 257,991 260,038 2,047
STAT...calls to get snapshot s 42,221 84,441 42,220
STAT...execute count 42,221 84,441 42,220
STAT...recursive calls 126,662 168,882 42,220
STAT...session pga memory 0 65,536 65,536
LATCH.shared pool 44,133 213,801 169,668
LATCH.library cache pin 86,473 256,185 169,712
LATCH.library cache 87,511 342,530 255,019
Run1 latches total versus runs -- difference and pct
Run1 Run2 Diff Pct
491,506 1,090,381 598,875 45.08%
PL/SQL procedure successfully completed.
Elapsed: 00:00:13.06Gints Plivna
http://www.gplivna.eu
Similar Messages
-
I'm attempting to sync several albums from itunes to iphoto. When select to sync all albums it copies over the previous recorded album. I tried to sync the Albums individually and the same thing happens. Any ideas on how to sync my albums?
Hi NWL1,
Thanks for the question. If I understand correctly, the iPhone won't update and is stuck. I would recommend that you read this article, it may be able to help you resolve or isolate the issue.
If you can't update or restore your iPhone, iPad, or iPod touch - Apple Support
Thanks for using Apple Support Communities.
Have a great day,
Mario -
I put an object and/or a text box on a page and then cannot select it - the Text cursor (not pointer, just the text cursor shows) is put on the object or text box and nothing happens. It is so frustrating! I then open up Everweb and the same thing, I create an object and then try and elect it to make it bigger etc and cannot. I know it must be something system wide as it happens in apps other than Pages.
I put an object and/or a text box on a page and then cannot select it - the Text cursor (not pointer, just the text cursor shows) is put on the object or text box and nothing happens. It is so frustrating! I then open up Everweb and the same thing, I create an object and then try and elect it to make it bigger etc and cannot. I know it must be something system wide as it happens in apps other than Pages.
-
Has anyone else found solution to Apple devices not 'seeing' each other on Home Share? I have a Macbook Air (new Nov'12) and Apple TV (new Dec'12). Software updated on both. Both are logged into the same Wifi network and the same iTunes account (I can view movies purchased from iTunes on my AppleTV). Home Sharing shows 'ON' for both devices. BUT...AppleTV shows no computers... and ... Itunes sidebar does not have a 'Shared' area at all. Help please as without this functionality, my Apple TV only provides portal to purchased (i.e. Netflix,...) content which I can get from Wii or Xbox.
I have already tried the following without success:
1. Homeshare DID work the first day after I setup Apple TV... but the next day it has not worked since then.
2. Powered off 30 sec then re-started (Apple TV & Macbook & iTunes login)
3. Checked Firewall settings per Home Sharing troubleshooting guide (correct settings)
4. Turning on Photostream in iPhoto and selecting iPhoto within iTunes and then checking to see if Photostream shows anything on AppleTV (it shows 'on' for my iTunes account but 'Zero' pictures found ... despite the >3,000 pictures showing avail in iTunes).
I also have 'Remote" app on my iPhone 4, with Home Sharing turned on (same Wifi network)... it has a very similar message as the Apple TV and same result that despite all devices having HomeShare 'on' they cannot see each other: "Remote will automatically find the iTunes libraries and Apple TVs that have Home Sharing turned on using the account xxxx (it lists my correct itunes account name)."I solved this by reset of the Wifi (unplug cable and power to both modem and wifi ... wait 60 sec ... plug in modem cable and power ... plug in wifi power and LAN to modem ... restart AppleTV and Mac ... Turn Home Share 'OFF' in iTunes then back "ON" ... it took ~60 sec for the AppleTV to pick up my Mac in computers.
-
Must have the same type and the same length
hi experts,
DELIVERY_PLANT data type STRING //from proxy class, can't be changed
BEGIN OF ty_citem,
article type matnr,
werks type werks,
END OF ty_citem,
LOOP AT it_items INTO lv_item.
lv_citem-article = lv_item-article.
lv_citem-werks = lv_item-DELIVERY_PLANT.
APPEND lv_citem TO GT_citem.
clear lv_citem.
ENDLOOP.
SELECT matnr werks
from marc
into table GT_marc
for all entries in GT_citem
where matnr = GT_citem-article and werks = GT_citem-werks.
error message here:When you use the addition "FOR ALL ENTRIES IN itab", the fields "WERKS"
and "GIT_CITEM-WERKS" must have the same type and the same length.Hi,
You know for statement FOR ALL ENTRIES in where clause data type and length should be match.
As per my understanding ,here GT_citem-werks is a string. But you know data type of WERKS_D is char with lencth 4.
Use the below select statement.
SELECT matnr werks
from marc
into table GT_marc
for all entries in GT_citem
where matnr = GT_citem-article and werks = GT_citem-werks+0(4).
Thanks.
Subhankar -
Hey. I have recently made an update on my daughters iMac, particularly the update OS X 10.9.4, when finished, its still asking for update and the same update stills remarked as ready in the apple update menu and remarked as 1 to go at the App store app. Why doesn't stop asking for update when its done like 5 times or more? Thanks for taking your time!
If you don't already have a current backup, back up all data, then reinstall the OS.* You don't need to erase the startup volume, and you won't need the backup unless something goes wrong. If the system was upgraded from an older version of OS X, you may need the Apple ID and password you used.
If you use FileVault 2, then before running the Installer you must launch Disk Utility and select the icon of the FileVault startup volume ("Macintosh HD," unless you gave it a different name.) It will be nested below another icon with the same name. Click the Unlock button in the toolbar and enter your login password when prompted. Then quit Disk Utility to be returned to the main Recovery screen.
There are ways to back up a computer that isn't fully functional. Ask if you need guidance.
If you installed the Java runtime distributed by Apple and still need it, you'll have to reinstall it. The same goes for Xcode. All other data will be preserved.
*The linked support article refers to OS X 10.9 ("Mavericks"), but the procedure is the same for OS X 10.7 ("Lion") and later. -
I cannot download Mavericks. Every time the file download stops a message appears that says the file is damaged and cannot be used to install Mavericks. I delete the file, download again and the same message appears. What can I do?
I only have one video project that I ever published to iDisk. It didn't have any music or photo files attatched to it, just a few clips stitched together. I can play these clips right now in the Event Library (so I know the source files are on my computer), but strangely, under the Project Library, the project is not there. I'm almost certain that I didn't store the project on iDisk; I just completed the video and published it to iDisk (as a .mov file I think) for family to see. I've tried to figure out how to get iDisk to stop looking for this project to no avail.
I don't know if others have experienced this, but if I click on any project and on the menu bar select Share --> Remove From --> Media Browser... it lists iPod, iPhone, iPad, tv, Computer and MobileMe. Why would MobileMe be an option here? This is the case for any video project I select. Didn't iLife '11 and/or OSX 10.8 remove all mention of MobileMe? I wonder if this is part of the problem too.
Edit: I just removed every project I have from the Media Browser. Still no luck. -
Hi
My USB CF (Compact Flash) Card reader is not mounting on my 2.5 GHZ Intel Core i5 iMac anymore.
Last week it worked fine to get pictures from my camera but now it won't mount at all.
I ejected it in the correct way rather than just disconnecting it but now i cannot get it to remount!
I cannot even see it in the disk utility or system profiler.
I have tried another card reader (a brand new one bought today) and the same problem exists. I've also tried different cards to see if that made a difference and they still arent being picked up on the Mac.
I have done all the usual things like rebooting, unplugging all other USB devices and then trying but nothing has worked.
I'm a photographer and I'm at my wits end here. I know the cards are fine as i have been using them without issue and they are also new.
Note: If I plug the camera in directly to the Mac, the Mac picks it up just fine as it always has done. Its just the card readers that it wont pick up anymore.
If anyone has any ideas at all other than the following (my so called friends advice) you'd earn my undting love:
Buy a PC
Use the camera (Thats why i bought the reader in the first place - importing RAW files from the camera is SLOW!)
Replace your CF cards (I have three 8GB cards two of which i had never used til today and they dont work either!)
Buy a new card reader (this is the 5th one in two days - none work on the Mac)
Many thanks in advance!
LIsaOK, restart in Safe Mode, this will clear some caches. It's possible one or more is corrupt. To restart in Safe Mode when you hear the start up tone hold down the Shift Key until you see a progress bar. Let it fully boot then restart normally and test.
Also I am assuming you have checked Finder - Preferences - General and see what boxes are checked in "Show these items on desktop." You can also mount an item in Disk Utility, simply highlight it and then look in the File menu for Mount..... -
Hi,
I have a user in our Hong Kong office that is unable to open a distribution group she has added to her Groups. She gets the error message "Cannot perform this action, and the cause is unknown. Contact your support team to investigate."
I can add the group and expand it, so can some of her colleague, and some cannot. Her colleagues who can have the same client and global policy settings as she does.
I read in a similar thread that this could be resolved by confirming the server times on Lync, AD (domain controller checked and Exchange but they were all correct and in sync.
The global policy is set to 250 max contacts - but does a DL count as 1 contact, or does it count all the people within the DG? I am getting HK to confirm she does not have too many contacts but I dont think this is the issue.
Anyone else come across this issue?
PhilYou can run the command Test-CsGroupExpansion to test the ability of a user to employ group expansion.
For the usage of the command, you can check
http://technet.microsoft.com/en-us/library/gg399009.aspx
Lisa Zheng
TechNet Community Support -
I installed Windows 7 in my Macbook pro, I can access Windows data in Mac, but I can't copy and delete it. and the same case while i am working in Windows. Could you please guide me if there is any solution, where I could copy/paste/delete my data.
OS X can natively read NTFS of Windows, but not write to it.
Windows can't read or write to HFS+ of OSX, and that's a good thing from a security standpoint.
Ideally if you share files between operating systems you should have a FAT/MSDOS formated USB key or hard drive. (exFAT external drive if any of your files are over 4GB in size) both these formats are universal for OS X or Windows.
If you install software into Windows and OS X to read each others formats, then you have to pay to update/upgrade it deal with headaches.
If you swtich between Windows and OS X a lot, don't need full hardware performance for Windows, you may consider installing virtual machine software like VMFusion or Parallels which can take a copy of your Windows in Bootcamp and place it into OS X as a file then run that copy of Windows in a window in OS X like so.
Advantage here is you run most of your light weight Windows programs like this at the same time as OS X.
Benefit is you can run just about any Windows or Linux version and OSX server editions (not client versions)
Bootcamp only allows Windows 7, that's it now.
You'll also be interested in two fre pieces of software, Carbon Copy Cloner and Winclone on macupdate.com.
CCC clones OS X partition and Winclone clones the Bootcamp partition. Valuable for you.
Good Luck -
I can not run the scanner in my main user, but only the second user and the same thing with updating apps! Why is this happening???
Welcome to the Apple Community.
Enter the details of her second account at system preferences> mail, contacts & calendars. -
Hi I buy pack but the problem is you already purchased in-app purchased but it hasn't been downloaded pls fix it for me and I buy before 15 days pack 19,99 and 4,99 and the same problem want or were can I fit it pls
The e-mail for World Strike support is: [email protected]
You need to contact them with your questions. -
In outlook 2013 Add-In, Adding dynamic menu to <splitButton idMso="DialMenu"> is working and the same code is not working in outlook
2010 Add-In. please let me know, if i am missing something. Below is the xml and screen shot
<contextMenu idMso="ContextMenuFlaggedContactItem">
<splitButton idMso="DialMenu">
<menu>
<dynamicMenu id="CallContactwithFreedomvoice
" label="CallContactwithFreedomvoice"
getContent="OnGetContenttest" insertAfterMso="Call"/>
</menu> </splitButton> </contextMenu>Hi Narasimha prasad2,
Based on the description, the context menu for the flagged contact doen't work in Outlook. I am tring to rerpoduce this issue however failed.
I suggest that you check the state of the add-in first to see wether the add-in was loaded successfully.
Regards & Fei
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
after I download Itunes, when trying to sync Ipod, message says "needs newer version of mobile support, uninstall Itunes, and reinstall Itunes, and the same process starts all over again. why is that?
Try removing and then reinstalling the Apple software using these instructions.
Removing and reinstalling iTunes, QuickTime, and other software components for Windows Vista or Windows 7
The above containes a link for XP. Also. make sure you install the correct Apple software, It comes in 32 and 64 bit and you need the one that is the same as the computer OS -
my ipod touch is stuck on the apple logo and after a while a white screen comes up and it restarts and the same thing all over agan. this happened to me before and after a while it turns on but why does it keep on doing this?
Try connecting the iPod Touch to your computer and restore it. http://support.apple.com/kb/HT1414
-
Since the introduction of iCloud, I've had this problem with the Apple ID. I've tried to "manage my Apple ID" but clicking the box to "make Apple ID and primary email address one and the same" but it just won't work. I'd given up and just ignored everything iCloud... I've ignored iCloud on my iPad mini and my iPhone 5 and now I'm going to get an iPhone 5s. I'm sure this will be an issue again. FYI, my Apple ID is in the format "a_xyz" only and it's working for purchases and upgrading of iOS, etc just not with iCloud. Any suggestions other than to create a new iCloud account with a different name? Thanks!
I don't have any suggestions that will help you resolve this issue other than to try posting here where there should be more iCloud experts.
https://discussions.apple.com/community/icloud/icloud_on_my_ios_device
Or contact Apple and ask for their help with this. Try here. I think Account and Setup would be the starting point.
https://getsupport.apple.com/Issues.action
Maybe you are looking for
-
How do I purchase games from the Itunes store?
I haven't had my Ipod in a little over a year. It used to be very easy to find the games store and now with the new version of Itunes I can't find any place on the site to find new games. Where do I go to view and purchase new games?
-
Hi Experts, This is Suma Mani ,my client having retail stores in India and back support is SAP ECC6.0.My business wants cummulative tax figures would requires post with sales docuemetns not line item wise. Evey busines transaction should be one tax l
-
How to confuse people with poorly thought out ideas.
So I'm looking to upgrade my phone and I see, "you're eligible for a free upgrade." however there's a $30 fee for this "free upgrade." Nonsense! After choosing my plan details for this new phone. (There were actually no changes in my plan from old ph
-
Returning an instance of a subclass
I like to think of myself as a purist when designing OO relationships. Specifically, I don't agree with having classes in one package (com.foo) reference classes in a 'sub' package (com.foo.bar). I also don't agree with a class instantiating subclass
-
Is the Waveburner UPC/EAN bug fixed in Logic 9?
Still on Logic 8 in OSX10.5.8 over here. Anyone seen this? In Waveburner, I go to (Disk->Disk Options->) I enter the UPC code for the CD I'm authoring. I click OK. I go back to it (Disk->Disk Options->) It's not there. Has this been fixed in Logic 9?