Operators in Spotlight
I can't get operators (AND, OR, NOT)to work in spotlight. Spotlight can't tell the difference between the operator and the search item. Does anyone know the proper syntax?
"AND" works if you leave a space but I can't find anything that works for "OR" or "NOT".
I have read everything I can find in the develoers forum but all of what's available is about the underlying code behind Spotlight or relates to writing a Raw Query.
I have done queries in both Spotlight and Find and saved the results in a Smart Folder. When you open the folder with a text editor you can see and edit the Raw Query that is the result of using Spotlight or Find. I don't think I am up to writing or editing Raw Queries.
All I need is to be able to add "OR" or "NOT" to a Spotlight or Find search and I wouldn't need to learn how to write a Raw Query.
Can anyone help me?
Hi, Robato.
What that's referencing in an off-handed way is using the Raw Query search criterion with a search expression in the Raw Query format. You can find out more about the Raw Query format by reading the "Query Expression Syntax" section of Spotlight Query Programming Topics. The metadata terms one can use in a Raw Query are discussed in Spotlight Metadata Attributes Reference.
I have a list of other Spotlight-related documentation in the "Related Links" section of my "Stop Spotlight Indexing" FAQ.
Good luck!
Dr. Smoke
Author: Troubleshooting Mac® OS X
Note: The information provided in the link(s) above is freely available. However, because I own The X Lab™, a commercial Web site to which some of these links point, the Apple Discussions Terms of Use require I include the following disclosure statement with this post:
I may receive some form of compensation, financial or otherwise, from my recommendation or link.
Similar Messages
-
Spotlight searches using operators
Recently learned that Spotlight can use operators to search, eg. "album:albumname," etc., but I have found that "song:songname" doesn't work. I find it very taxing to have to remember either the album (or artist, which successfully searches) of every song on my Mac. Anyone know if there is an Automator/Terminal way to add this to Spotlight's searching parameters?
It seems that I (somehow) wasn't thinking at all when I posted this question. I now realize that only typing the name of the song will bring it up, so that part of my question is answered. Not sure how I overlooked something that monumental.
In regards to the larger question here, is there any way to add other operators to Spotlight search? I have found articles on 10.5 which claim that the ones that exist are in "/System/Library/Frameworks/CoreServices.framework/...," but that folder doesn't exist in 10.6.2. Has this been moved?
Message was edited by: The Incendiary -
Boolean operators (and/or, etc.) in bridge spotlight search?
Anyone know if boolean operators are possible in Bridge's spotlight search field in the upper right?
I realize it's available through edit > find, and that smart collections can be saved, but looking for faster ways.
Would be much obliged for any help, thanks!Anyone know if boolean operators are possible in Bridge's spotlight search field in the upper right?
I realize it's available through edit > find, and that smart collections can be saved, but looking for faster ways.
Would be much obliged for any help, thanks! -
Find function and spotlight - some reactions
Hi,
I just got at new iMac and I'm trying to get hip to what's what with Leopard. I hit a glitch when it came time to look for a file on the hard drive. Is it me or is the find function almost useless? (I've given up on Spotlight.) When I select File > Find... a window comes up that indicates the search is "This Mac". Why not use the name of the hard drive? Further along the top of this window, "Contents" is selected. (I want "File name".) Who wants to start a search with contents??? If I select a different hard drive, this row of options disappears and I just have the search field in the top right of the window. If I type into the search field, it goes back to searching content on my mac?!
When you initiate a new search, the window is small and you inevitably have to resize the columns and window. And what's with the smart folder icon at the top of the window? For me, the results show too much info.
Oh, and I still "like" the way it displays the file path of the found file. It's ok if the file isn't buried 10 folders deep or one has a gigantic 24" screen where resizing will show it. It seems that the find function has gotten progressively worse as the cats have come and gone. This will be unbearable at work where I have to search 100's of folders on a Windows share digging through 200,000 plus graphics and word pro files.
Oh, I found out that when I select a file name to copy and paste it, the extension is not hilighted. Is this going to get stupid?
And in the end, what prompted me to use the find file in the first place was I wanted to import the ical .abbu file to my new iMac. I just couldn't import this .abbu file from my other machine. Not migrating assistant, copying that iCal '.abbu' file into a folder--wherever that is on my iMac now--or importing the file using iCal will set my new iCal like the old one.
Keith
<Edited by Moderator>soehnk wrote:
Hi,
I just got at new iMac and I'm trying to get hip to what's what with Leopard. I hit a glitch when it came time to look for a file on the hard drive. Is it me or is the find function almost useless?
It has some quirks, and it's not always obvious how to use it to its best, but it's far from useless.
(I've given up on Spotlight.)
I assume you mean the Spotlight menu. Spotlight still does the searching in Finder windows. And when you know its ins and outs (for instance, it searches both Contents and Name, you should adjust the categories listed in the menu thru the Spt Pref pane since only 20 items are listed, you can see the path to a listed item, or have it revealed in the Finder; you can use keywords for more targeted searches... and so on).
When I select File > Find... a window comes up that indicates the search is "This Mac". Why not use the name of the hard drive?
It's letting you search everything (all mounted volumes), not just the internal drive, giving you the widest possible search area. The bigger problem with this element is that the second "search area" option, which is the folder window you started in, isn't the default selection. I suppose the thinking there was that if you're looking in a folder and can't find what you want, you want to widen your search, not narrow it with more criteria. But most of us want that optional folder set as the default when we go into Find!
Further along the top of this window, "Contents" is selected. (I want "File name".) Who wants to start a search with contents???
I suppose the people who want to start with Contents aren't complaining, so we don't hear from them. But I agree that File Name should be the default. However, if you use Command-Shift-F instad of Command-F (or hold Shift while opening the File menu the Find command changes to Find By Name), you'll get a Search window whose first criterion bar is already set to "Name contains..." and you can go right for the file name.
If I select a different hard drive, this row of options disappears and I just have the search field in the top right of the window. If I type into the search field, it goes back to searching content on my mac?!
Yes, one of the ways to get out of a Search mode window is to click on something else for the window to display; it really should set the Search area to a disk or folder you click on. But when you do go back into Find mode by typing in the Search field, your optional Search area is now the volume you just clicked on.
When you initiate a new search, the window is small and you inevitably have to the columns and window. And what's with the smart folder icon at the top of the window? For me, the results show too much info.
If your search is in a current window rather than a new one, it inherits the size of the current window; try clicking the zoom button before you go into Find mode.
Not sure what your beef with the Smart Folder icon in the window. The Find window isn't a regular folder, and it behaves just like a Smart Folder, really, and can be turned into a Smart Folder with a click of the Save button; this detail makes more sense to me than a regular folder icon or another icon altogether.
I assume that by "show too much info" you mean the search isn't targeted enough and the list is too long? Because the only info it shows for each hit is the name, kind, and last opened date. It's missing the basic Size column, so even if you Find according to Size, you can't sort according to size! I'd call that not enough info!
So, I'm guessing you mean "too much info" as "too many files that don't match what I'm looking for". But you can narrow your search all sorts of ways both in the Search field with multiple words, literal strings, boolean operators ("this AND that" "this OR that but NOT the other thing") and in as many criteria bars as you want to define kind, created or modified dates, folders not files, a partial file resize name PLUS a few words of the content....
Oh, and I still "like" the way it displays the file path of the found file. It's ok if the file isn't buried 10 folders deep or one has a gigantic 24" screen where resizing will show it. It seems that the find function has gotten progressively worse as the cats have come and gone. This will be unbearable at work where I have to search 100's of folders on a Windows share digging through 200,000 plus graphics and word pro files.
Are you referring to the squeezed-up list of folders in the Path bar at the bottom of the window? Hovering your cursor over any of the squeezed-up names shows you the full names of the interim files.
As for digging through 200K files... again, narrowing your search with parameters like "name contains..." "modified before/after" "kind is image" or "kind is JPEG" and so on... all this is available to dig through that mountain, and it's the same kind of parameters you'd have to define for any search engine to know what you want and narrow the choices.
Oh, I found out that when I select a file name to copy and paste it, the extension is not hilighted. Is this going to get stupid?
Well, here we totally disagree. The non-hilite on the extension is a boon - you can select a name and rename the file without having to retype the extension. When you want the name with the extension, just select the file (not the name) and choose Copy - you can paste the whole name that way. (Other info is copied with a select-and-Copy procedure. Depending on where you do the paste, you get different things: it copies the icon, too, so if you want to paste it in a Get Info window as a custom icon, you can use that; it copies the entire file, to, so you can Copy a file in one folder and Paste it in another. The Mac pretty much knows which part of the copied info you want to use based on where you do the pasting.)
And in the end, what prompted me to use the find file in the first place was I wanted to import the ical .abbu file to my new iMac. I just couldn't import this .abbu file from my other machine. Not migrating assistant, copying that iCal '.abbu' file into a folder--wherever that is on my iMac now--or importing the file using iCal will set my new iCal like the old one.
.abbu is for Address Book, .icbu is for iCal - I assume this was just a typo on your part. But whichever one you meant, I have no trouble finding either one (not that I had them before I tested this based on your comment, since I use Time Machine for backing them up). However, I created both program-based backups, and each was instantly found both thru the Spotlight menu and a Search window with no problem. the icbu file's Kind is iCal Backup file; searching by Kind is "iCal Backup" should get it for you. The abbu file Kind is "Address Book Archive FIle"; searching for Kind is with that whole, or partial, description should help you find it.
sharon -
Spotlight questions...
I would like to search one of our server drives for all files above a specified size to clean up videos that people have downloaded.
This was easy back on 10.3.9
With spotlight I tell it to search for files more than 15mb on the drive with users folders, and wind up getting 10 results when there should be WAY more.
Is there a way to access the old "find/search" window?
If not, how do I make spotlight actually search the entire disk? It seems like its leaving lots of stuff out.You wrote: "I'm actually physically on the server (console). Drives are on an Xserve RAID array and I am searching directly from the host server."Sorry, I misunderstood. I've not tested Spotlight in that context.
You wrote: "We'd like to search in a manner similar to the "old" search from 10.3.x"That function no longer really exists. Find is implemented in Spotlight.
Is the disk in question a single volume or multiple volumes?
I've found that if indexing is disabled on a volume using the command
sudo mdutil -i off /pathtovolume
then the Find command behaves like the old Find in earlier versions of Mac OS X when searching for file system metadata. However, in this context you can't use the Spotlight "classifications" of data, nor can you search for content. For example, if indexing has been disabled on a volume, to search for movies, instead of:
Kind: Movie
you have to search for specific extensions representing movie files, using the Name Extension criteria, e.g.
Name Extension: wmv
or
Name Extension: mov
Criteria like Size > Greater than > _ > MB also work in that context. Searches for this kind of file system metadata actually search the disk directory, not the Spotlight index.
Searches for the different "Name Extension" criteria can be saved as Smart Folders.
Note that indexing must be disabled as noted above with the mdutil command. Find will not work as described if the volume has been added to Privacy. This is one of the anomalies in Spotlight between Find and the -i off flag I describe in my "Stop Spotlight Indexing" FAQ.
Again, I've not tested any of this with Xserve RAID, but you can play around with it.
You can look for alternative search utilities by searching MacUpdate or Version Tracker for either search or find. One of the most popular, EasyFind, is not going to help you here since it is based on the UNIX® find command, which does not support operators like ">".
You might also try your question on the XServe RAID Discussion to see what others using that platform have experienced.
Good luck!
Dr. Smoke
Author: Troubleshooting Mac® OS X
Note: The information provided in the link(s) above is freely available. However, because I own The X Lab™, a commercial Web site to which some of these links point, the Apple Discussions Terms of Use require I include the following disclosure statement with this post:
I may receive some form of compensation, financial or otherwise, from my recommendation or link. -
Logical operators in Oracle select query
Hello all,
Can i use logical operators in oracle select queries?
for 1 and 0 =0 ; 1 or 0 =0
if i have two fileds in a table COL1 have a value of 1010 and COL2 have a value of 0001.
Is there any way to use select col1 or col2 from table? where or is a logical operator?
Regards,Hi,
NB wrote:
Hello all,
Can i use logical operators in oracle select queries?Sure; Oracle has the logical operators AND, NOT and OR. All the comparison operators, including >, >=, = !=, EXISTS, IN, IS NULL, LIKE and REGEXP_LIKE are really logical operators, since they return logical values. You can use them in SELECT statements, and other places, too.
for 1 and 0 =0 ; 1 or 0 =0
if i have two fileds in a table COL1 have a value of 1010 and COL2 have a value of 0001.It's unclear what you want. Maybe you'd be interested in the BITAND function:
http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/functions014.htm#sthref1080
BITAND is the only logical function that I know of. Many other functions, especially numberical fucntions such as MOD, have applications in logic.
Is there any way to use select col1 or col2 from table? where or is a logical operator?Whenever you have a question, please post a little sample data (CREATE TABLE and INSERT statements), and also post the results you want from that data.
Explain how you get those results from that data.
Always say which version of Oracle you're using. -
Table Filter Problem with Operators And ,Or
Hi ,
Version : Jdeveloper 11.1.1.5
I Created one view object based on query( Select Empno,Ename From Emp)
Based on View Object - I created adf table .
In Emp table data is as shown below
Empno Ename
1 Hari
2 Ramu and Hari
I made "Filterable" Property true and FilterFeature is CaseInsensitive
When i query 'Ramu a' it will retrive correctly,if i query 'Ramu and' it will show no data to display
Please suggest me how to solve
Note : What i noticed is and ,or are treating as operators
Thanks
SkHi,
tried the same with JDeveloper 11.1.1.6 and it works without problems. The only problem that will arise is if you search for e.g. "Mickey and" to find Mickey and Mouse. Here "and" is recognized as a reserved keyword. However, you work around this by using "Mickey an". Note that you can intercept the table query using a QueryListener to handle cases where key words are used within a string
Frank
Edited by: Frank Nimphius on Apr 27, 2012 7:55 AM -
How can I disable files from being shown in spotlight?
Hi All,
In my spotlight preferences I've enabled only Applications, Folders, and System Preferences. However, in almost all of my searches, many individual files are shown. These are usualy .java, .jar, or .html even.
To exacerbate the problem, spotlight seems to be looking inside the files when it searches/indexes. So I get many files that dont have my search terms in the title. Basically, the things I want are at the bottom, far below a bunch of files that I don't want to see.
Is there any way to filter these out permanently?Found a solution. It is this. But Thomas is correct in assuming I am using it as an application launcher. This fix allows me to resume this activity as it was in Snow Leopard.
http://hints.macworld.com/article.php?story=20110805192212447 -
Spotlight is not working on brand new Mac mini
Hi,
I got an issue with two brand new Mac minis running 10.7.3 (11D50d):
Spotlight is not working. I'm only getting the Wikipedia-Search.
Here's what I did:
Installation:
- took the stock Minis and set up two users, admin and user (limited account)
- updatet the System
- installed manually: Adobe Reader X, Office 2011, Firefox 12, Flip4Mac, Perian, Cyberduck, Google Earth 6.2 (the installer without the updater), VLC 2
- installed using AppStore: CalendarBar, TextWrangler, Unarchiever
- copied a few documents (Word and Excel files) from a PC to the Desktop
Troubleshooting:
- tried to restart Spotlight by adding the entire harddrive to privacy using »Spotlight« within the System Preferences
- that threw an error "no priviliges"
- started the System from the recovery system (on an USB-thumbdrive) and repaired permissions
- that did not help
- tried to restart Spotlight through the Terminal, running the command: sudo mdutil -E /
- that command returned: No index.
- the tried: sudo mdutil -i on /
- returned: Error: unable to perform operation. (-400) No index.
- went the hard way
- unloaded the daemon: sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.metadata.mds.plist
- erased the Spotlight folder: sudo rm -fr .Spotlight-V100/
- loaded the daemon: sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.metadata.mds.plist
That made everything work fine until I did a restart of the System. After the mini restarted I was back at square one...
Does anyone have an idea how to fix this issue?
Apple support suggested to reinstall the system. Something I can't do right now, as people need to work on those computers and cannot take a tow hour break...Hi Ray Land,
We can help narrow down the cause. What operating system are you using on your new Mac Mini?
If you are running the Mountain Lion OS, you can download the latest driver here. An important note is that the current print queue must be deleted before installing the new driver. This will ensure proper communication.
If this doesn't work or you need further assistance, please contact us here.
Did this answer your question? Please click the Accept as Solution button so that others may find the answer as well. -
Spotlight does NOT work - tried EVERYTHING
Running older Intel Mac Pro... Mountain Lion
Spotlight just stopped working - it returns nothing but webpage suggestions.
There are NO disks added under the Spotlight System Preferences.
Trying to add and then remove only results in the "Privacy List Error The item couldn't be addred because you don't have the appropriate permissions.
I've rebuilt permissions. No go.
I've killed SystemUIServer in Activities Monitor - nada.
I've used the info here on How to Disable (or Enable) Spotlight in Mac OS X Lion which includes the terminal commands for killing Spotlight, restarting again, and forcing reindexing. Nothing. Well almost nothing- I got it to re-index for a bit last night... But when you use Spotlight.... nothing.
I have an ugly suspicion it has to do with perceived ownership of the disks by the OS - anyone care to take me up on this? Here's why:
I you reveal the hidden files you see this:
When I "Get Info" (Command-I) I see these permissions... the disk first, and then the .Spotlight-V100 folder:
So why does the .Spotlight-V100 say that everyone has "No Access"? But looking at my Mac Mini these settings seem to be correct.
I tried changing ownership on the everyone to "Read" (which didn't work everytime I tried until I started writing this of course) but it just returns the same Privacy Access error when you try to add the disk to the Spotlight Preferences Privacy list again. I tried changing it to Read & Write... same thing.
Now inside the Spotlight-V100 folder is the VolumeConfiguration.plist file - I'm wondering if something in these preferences (which you can read unless you change the setting to "Read" where it is first set 'everyone' as 'no access') might give a clue - so here is the content of that file and I'll leave this for now to see if anyone has any clue what's going on here. Thanks
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Annotations</key>
<dict>
<key>Creation_Predicates</key>
<dict>
<key>false</key>
<false/>
<key>fstype.hfs</key>
<true/>
<key>interconnect.sata</key>
<true/>
<key>is.alreadyindexed</key>
<false/>
<key>is.automount</key>
<false/>
<key>is.backupstore</key>
<false/>
<key>is.backupvolume</key>
<false/>
<key>is.bootablevolume</key>
<true/>
<key>is.cameramedia</key>
<false/>
<key>is.diskimage</key>
<false/>
<key>is.dontbrowse</key>
<false/>
<key>is.ejectable</key>
<false/>
<key>is.external</key>
<false/>
<key>is.externalvolumes.defaultoff</key>
<false/>
<key>is.externalvolumes.ignore</key>
<false/>
<key>is.filevault</key>
<false/>
<key>is.forcedefaultindex</key>
<false/>
<key>is.forcefsonly</key>
<false/>
<key>is.home</key>
<false/>
<key>is.internal</key>
<true/>
<key>is.ipod</key>
<false/>
<key>is.local</key>
<true/>
<key>is.lowdiskspace</key>
<false/>
<key>is.mirrored.idisk</key>
<false/>
<key>is.mobilebackups</key>
<false/>
<key>is.network</key>
<false/>
<key>is.quarantined</key>
<false/>
<key>is.readonly</key>
<false/>
<key>is.removable</key>
<false/>
<key>is.rootfs</key>
<true/>
<key>is.safeboot</key>
<false/>
<key>is.syntheticmount</key>
<false/>
<key>is.tinyvolume</key>
<false/>
<key>is.windowsbootablevolume</key>
<false/>
<key>is.xsan</key>
<false/>
<key>policy.location.volume</key>
<true/>
<key>self.appleinternal</key>
<false/>
<key>self.server</key>
<false/>
<key>status.neverindex</key>
<false/>
<key>supports.catsearch</key>
<true/>
<key>supports.fileids</key>
<true/>
<key>supports.volfs</key>
<true/>
<key>true</key>
<true/>
<key>uuid.b449cee2-6ad5-3b8a-a749-9e6d14c278b1</key>
<true/>
</dict>
<key>DefaultStore_EffectiveSearch</key>
<integer>3</integer>
<key>DefaultStore_RequestedSearch</key>
<integer>3</integer>
</dict>
<key>ConfigurationCreationDate</key>
<date>2013-02-15T00:07:09Z</date>
<key>ConfigurationCreationVersion</key>
<string>Version 10.8.2 (Build 12C60)</string>
<key>ConfigurationModificationDate</key>
<date>2013-02-15T00:07:09Z</date>
<key>ConfigurationModificationVersion</key>
<string>Version 10.8.2 (Build 12C60)</string>
<key>Exclusions</key>
<array/>
<key>Options</key>
<dict>
<key>ConfigurationType</key>
<string>Default</string>
</dict>
<key>Stores</key>
<dict>
<key>7577F89E-857D-4CB6-B9D0-E937F1944380</key>
<dict>
<key>CreationDate</key>
<date>2013-02-15T00:07:09Z</date>
<key>CreationVersion</key>
<string>Version 10.8.2 (Build 12C60)</string>
<key>IndexVersion</key>
<integer>95</integer>
<key>PartialPath</key>
<string>/</string>
<key>PolicyDate</key>
<date>2013-02-15T00:07:09Z</date>
<key>PolicyLevel</key>
<string>kMDConfigSearchLevelReadWrite</string>
<key>PolicyVersion</key>
<string>Version 10.8.2 (Build 12C60)</string>
</dict>
</dict>
</dict>
</plist>Hi Linc,
Thanks for picking up my thread and offering your insights.
Going to Console and filtering for mdworker reveals no entries what so ever. I recognize mdworker as one of the key components of Spotlight so suggests it's not running. I also see that Console is posting repeated crashes for for
LaunchServices/5123589
here's the full entry:
2/15/13 8:28:20.942 PM ReportCrash[637]: failed looking up LS service ( scCreateSystemService returned MACH_PORT_NULL, called from SetupCoreApplicationServicesCommunicationPort, so using client-side NULL calls.
2/15/13 8:28:20.942 PM ReportCrash[637]: LaunchServices/5123589: Unable to lookup coreservices session port for session 0x186a0 uid=0 euid=0
2/15/13 8:28:20.998 PM com.apple.launchd[1]: (com.apple.metadata.mds[640]) Job appears to have crashed: Segmentation fault: 11
2/15/13 8:28:20.998 PM com.apple.launchd[1]: (com.apple.metadata.mds) Throttling respawn: Will start in 10 seconds
2/15/13 8:28:21.107 PM ReportCrash[637]: Saved crash report for mds[640] version 707.3 to /Library/Logs/DiagnosticReports/mds_2013-02-15-202821_COMPUTER_NAME.crash
this certainly appears also to be Spotlight because running this in Terminal...
sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.metadata.mds.plist
and the crash reports stop. Run this to reload Spotlight...
sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.metadata.mds.plist
and the errors start again.
This is the crash report noted above - pretty sure this is what you want now - I see no mdsworker but mds errors all through...
Thoughts?
Thanks.
Process: mds [640]
Path: /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/Metadat a.framework/Versions/A/Support/mds
Identifier: mds
Version: 707.3
Code Type: X86-64 (Native)
Parent Process: launchd [1]
User ID: 0
Date/Time: 2013-02-15 20:28:20.498 -0500
OS Version: Mac OS X 10.8.2 (12C60)
Report Version: 10
Crashed Thread: 9 Dispatch queue: <MDSDiskStore 0x7fd02500ac00 shutdown:NO got shutdown notification:NO>
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000008
VM Regions Near 0x8:
-->
__TEXT 000000010514c000-000000010526c000 [ 1152K] r-x/rwx SM=COW /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/Metadat a.framework/Versions/A/Support/mds
Application Specific Information:
[0x105b70000](Error) IndexGeneral in ssize_t fd_pread(fd_ptr, void *, size_t, off_t):pread(-1 , o:0, s:0) err:2
[0x105b70000](Error) IndexCI in _Bool store_stream_init(store_stream_t *, fd_ptr, _Bool):store_stream_init err:2
[0x105b70000](Warning) IndexStore in int db_restore_dirty_chunk_info(int, db_dirty_chunk_info *):Restore error: 2, recovering from shadow
[0x105b70000](Error) IndexState in int _SIOpenIndexFilesWithState(SIRef, uint32_t, _Bool, _Bool, _Bool, _Bool *, DocID *, CIDocCounts *):ContentInde
Thread 0:: Dispatch queue: com.apple.main-thread
0 libsystem_kernel.dylib 0x00007fff86abe686 mach_msg_trap + 10
1 libsystem_kernel.dylib 0x00007fff86abdc42 mach_msg + 70
2 com.apple.CoreFoundation 0x00007fff84b22803 __CFRunLoopServiceMachPort + 195
3 com.apple.CoreFoundation 0x00007fff84b27ee6 __CFRunLoopRun + 1078
4 com.apple.CoreFoundation 0x00007fff84b276b2 CFRunLoopRunSpecific + 290
5 mds 0x000000010515aa54 0x10514c000 + 59988
6 libdyld.dylib 0x00007fff8a4327e1 start + 1
Thread 1:
0 libsystem_kernel.dylib 0x00007fff86ac06d6 __workq_kernreturn + 10
1 libsystem_c.dylib 0x00007fff85029eec _pthread_workq_return + 25
2 libsystem_c.dylib 0x00007fff85029cb3 _pthread_wqthread + 412
3 libsystem_c.dylib 0x00007fff85014171 start_wqthread + 13
Thread 2:: Dispatch queue: com.apple.libdispatch-manager
0 libsystem_kernel.dylib 0x00007fff86ac0d16 kevent + 10
1 libdispatch.dylib 0x00007fff8d81ddea _dispatch_mgr_invoke + 883
2 libdispatch.dylib 0x00007fff8d81d9ee _dispatch_mgr_thread + 54
Thread 3:
0 libsystem_kernel.dylib 0x00007fff86ac06d6 __workq_kernreturn + 10
1 libsystem_c.dylib 0x00007fff85029eec _pthread_workq_return + 25
2 libsystem_c.dylib 0x00007fff85029cb3 _pthread_wqthread + 412
3 libsystem_c.dylib 0x00007fff85014171 start_wqthread + 13
Thread 4:: Dispatch queue: <MDSDiskStore 0x7fd026826400 shutdown:NO got shutdown notification:NO>
0 libsystem_kernel.dylib 0x00007fff86ac0ae6 fsync + 10
1 com.apple.spotlight.index 0x000000010537b38b fd_sync + 381
2 com.apple.spotlight.index 0x00000001053a71d8 _CIMetaInfoSync + 157
3 com.apple.spotlight.index 0x00000001053a73ad CIMetaInfoCreate + 377
4 com.apple.spotlight.index 0x00000001052dfbaa SICreateNewIndex + 1106
5 mds 0x0000000105182318 0x10514c000 + 221976
6 mds 0x0000000105181a7a 0x10514c000 + 219770
7 mds 0x0000000105173868 0x10514c000 + 161896
8 mds 0x00000001051cd47e 0x10514c000 + 529534
9 mds 0x00000001051b4962 0x10514c000 + 428386
10 mds 0x00000001051b4b21 0x10514c000 + 428833
11 libdispatch.dylib 0x00007fff8d81b0b6 _dispatch_client_callout + 8
12 libdispatch.dylib 0x00007fff8d81c47f _dispatch_queue_drain + 235
13 libdispatch.dylib 0x00007fff8d81c2f1 _dispatch_queue_invoke + 52
14 libdispatch.dylib 0x00007fff8d81c1c3 _dispatch_worker_thread2 + 249
15 libsystem_c.dylib 0x00007fff85029cab _pthread_wqthread + 404
16 libsystem_c.dylib 0x00007fff85014171 start_wqthread + 13
Thread 5:
0 libsystem_kernel.dylib 0x00007fff86ac06d6 __workq_kernreturn + 10
1 libsystem_c.dylib 0x00007fff85029eec _pthread_workq_return + 25
2 libsystem_c.dylib 0x00007fff85029cb3 _pthread_wqthread + 412
3 libsystem_c.dylib 0x00007fff85014171 start_wqthread + 13
Thread 6:
0 libsystem_kernel.dylib 0x00007fff86ac06d6 __workq_kernreturn + 10
1 libsystem_c.dylib 0x00007fff85029eec _pthread_workq_return + 25
2 libsystem_c.dylib 0x00007fff85029cb3 _pthread_wqthread + 412
3 libsystem_c.dylib 0x00007fff85014171 start_wqthread + 13
Thread 7:
0 libsystem_kernel.dylib 0x00007fff86ac0ffa read + 10
1 mds 0x0000000105155ced 0x10514c000 + 40173
2 libsystem_c.dylib 0x00007fff85027742 _pthread_start + 327
3 libsystem_c.dylib 0x00007fff85014181 thread_start + 13
Thread 8:
0 libsystem_kernel.dylib 0x00007fff86ac06d6 __workq_kernreturn + 10
1 libsystem_c.dylib 0x00007fff85029eec _pthread_workq_return + 25
2 libsystem_c.dylib 0x00007fff85029cb3 _pthread_wqthread + 412
3 libsystem_c.dylib 0x00007fff85014171 start_wqthread + 13
Thread 9 Crashed:: Dispatch queue: <MDSDiskStore 0x7fd02500ac00 shutdown:NO got shutdown notification:NO>
0 com.apple.spotlight.index 0x00000001052ecffc SISetTransactionCount + 212
1 mds 0x00000001051f951f 0x10514c000 + 709919
2 mds 0x00000001051fa08f 0x10514c000 + 712847
3 mds 0x0000000105172b82 0x10514c000 + 158594
4 mds 0x0000000105181eb1 0x10514c000 + 220849
5 mds 0x0000000105173868 0x10514c000 + 161896
6 mds 0x00000001051cd47e 0x10514c000 + 529534
7 mds 0x00000001051b4962 0x10514c000 + 428386
8 mds 0x00000001051b4b21 0x10514c000 + 428833
9 libdispatch.dylib 0x00007fff8d81b0b6 _dispatch_client_callout + 8
10 libdispatch.dylib 0x00007fff8d81c47f _dispatch_queue_drain + 235
11 libdispatch.dylib 0x00007fff8d81c2f1 _dispatch_queue_invoke + 52
12 libdispatch.dylib 0x00007fff8d81c1c3 _dispatch_worker_thread2 + 249
13 libsystem_c.dylib 0x00007fff85029cab _pthread_wqthread + 404
14 libsystem_c.dylib 0x00007fff85014171 start_wqthread + 13
Thread 10:: Dispatch queue: <MDSDiskStore 0x7fd026820400 shutdown:NO got shutdown notification:NO>
0 libsystem_kernel.dylib 0x00007fff86abfb26 __fcntl + 10
1 libsystem_kernel.dylib 0x00007fff86abf0cb fcntl + 232
2 com.apple.spotlight.index 0x000000010537b303 fd_sync + 245
3 com.apple.spotlight.index 0x00000001054164f7 dirty_datastore_locked + 263
4 com.apple.spotlight.index 0x000000010541e025 add_dirty_chunk + 195
5 com.apple.spotlight.index 0x0000000105417b48 page_alloc + 290
6 com.apple.spotlight.index 0x0000000105417987 db2_store_obj + 325
7 com.apple.spotlight.index 0x00000001052d730d si_create_indexmetadata + 213
8 com.apple.spotlight.index 0x00000001052e5933 SIInitIndex + 15244
9 com.apple.spotlight.index 0x00000001052e0bc2 SICreateNewIndex + 5226
10 mds 0x0000000105182318 0x10514c000 + 221976
11 mds 0x0000000105181a7a 0x10514c000 + 219770
12 mds 0x0000000105173868 0x10514c000 + 161896
13 mds 0x00000001051cd47e 0x10514c000 + 529534
14 mds 0x00000001051b4962 0x10514c000 + 428386
15 mds 0x00000001051b4b21 0x10514c000 + 428833
16 libdispatch.dylib 0x00007fff8d81b0b6 _dispatch_client_callout + 8
17 libdispatch.dylib 0x00007fff8d81c47f _dispatch_queue_drain + 235
18 libdispatch.dylib 0x00007fff8d81c2f1 _dispatch_queue_invoke + 52
19 libdispatch.dylib 0x00007fff8d81c1c3 _dispatch_worker_thread2 + 249
20 libsystem_c.dylib 0x00007fff85029cab _pthread_wqthread + 404
21 libsystem_c.dylib 0x00007fff85014171 start_wqthread + 13
Thread 11:: Dispatch queue: <MDSDiskStore 0x7fd027807a00 shutdown:NO got shutdown notification:NO>
0 libsystem_kernel.dylib 0x00007fff86ac0fbe pwrite + 10
1 com.apple.spotlight.index 0x00000001053a6f02 _copyFile + 981
2 com.apple.spotlight.index 0x00000001053a70f4 copyFile + 12
3 com.apple.spotlight.index 0x000000010541213d db2_update_datastore_state + 163
4 com.apple.spotlight.index 0x00000001052dde36 _SIOpenIndex + 3670
5 com.apple.spotlight.index 0x00000001052e0ea8 SIOpenIndex + 282
6 mds 0x0000000105182396 0x10514c000 + 222102
7 mds 0x0000000105181854 0x10514c000 + 219220
8 mds 0x0000000105173868 0x10514c000 + 161896
9 mds 0x00000001051cd47e 0x10514c000 + 529534
10 mds 0x00000001051b4962 0x10514c000 + 428386
11 mds 0x00000001051b4b21 0x10514c000 + 428833
12 libdispatch.dylib 0x00007fff8d81b0b6 _dispatch_client_callout + 8
13 libdispatch.dylib 0x00007fff8d81c47f _dispatch_queue_drain + 235
14 libdispatch.dylib 0x00007fff8d81c2f1 _dispatch_queue_invoke + 52
15 libdispatch.dylib 0x00007fff8d81c1c3 _dispatch_worker_thread2 + 249
16 libsystem_c.dylib 0x00007fff85029cab _pthread_wqthread + 404
17 libsystem_c.dylib 0x00007fff85014171 start_wqthread + 13
Thread 12:
0 libsystem_kernel.dylib 0x00007fff86ac06d6 __workq_kernreturn + 10
1 libsystem_c.dylib 0x00007fff85029eec _pthread_workq_return + 25
2 libsystem_c.dylib 0x00007fff85029cb3 _pthread_wqthread + 412
3 libsystem_c.dylib 0x00007fff85014171 start_wqthread + 13
Thread 13:: Dispatch queue: <MDSDiskStore 0x7fd02300ee00 shutdown:NO got shutdown notification:NO>
0 libsystem_kernel.dylib 0x00007fff86ac0fbe pwrite + 10
1 com.apple.spotlight.index 0x00000001053a6f02 _copyFile + 981
2 com.apple.spotlight.index 0x00000001053a70f4 copyFile + 12
3 com.apple.spotlight.index 0x000000010541213d db2_update_datastore_state + 163
4 com.apple.spotlight.index 0x00000001052dde36 _SIOpenIndex + 3670
5 com.apple.spotlight.index 0x00000001052e0ea8 SIOpenIndex + 282
6 mds 0x0000000105182396 0x10514c000 + 222102
7 mds 0x0000000105181854 0x10514c000 + 219220
8 mds 0x0000000105173868 0x10514c000 + 161896
9 mds 0x00000001051cd47e 0x10514c000 + 529534
10 mds 0x00000001051b4962 0x10514c000 + 428386
11 mds 0x00000001051b4b21 0x10514c000 + 428833
12 libdispatch.dylib 0x00007fff8d81b0b6 _dispatch_client_callout + 8
13 libdispatch.dylib 0x00007fff8d81c47f _dispatch_queue_drain + 235
14 libdispatch.dylib 0x00007fff8d81c2f1 _dispatch_queue_invoke + 52
15 libdispatch.dylib 0x00007fff8d81c1c3 _dispatch_worker_thread2 + 249
16 libsystem_c.dylib 0x00007fff85029cab _pthread_wqthread + 404
17 libsystem_c.dylib 0x00007fff85014171 start_wqthread + 13
Thread 14:
0 libsystem_kernel.dylib 0x00007fff86ac06d6 __workq_kernreturn + 10
1 libsystem_c.dylib 0x00007fff85029eec _pthread_workq_return + 25
2 libsystem_c.dylib 0x00007fff85029cb3 _pthread_wqthread + 412
3 libsystem_c.dylib 0x00007fff85014171 start_wqthread + 13
Thread 15:
0 libsystem_kernel.dylib 0x00007fff86ac06d6 __workq_kernreturn + 10
1 libsystem_c.dylib 0x00007fff85029eec _pthread_workq_return + 25
2 libsystem_c.dylib 0x00007fff85029cb3 _pthread_wqthread + 412
3 libsystem_c.dylib 0x00007fff85014171 start_wqthread + 13
Thread 16:
0 libsystem_kernel.dylib 0x00007fff86ac06d6 __workq_kernreturn + 10
1 libsystem_c.dylib 0x00007fff85029eec _pthread_workq_return + 25
2 libsystem_c.dylib 0x00007fff85029cb3 _pthread_wqthread + 412
3 libsystem_c.dylib 0x00007fff85014171 start_wqthread + 13
Thread 9 crashed with X86 Thread State (64-bit):
rax: 0x00000000ffffffff rbx: 0x0000000000000000 rcx: 0x0000000000000000 rdx: 0x0000000000000082
rdi: 0x00007fd022829e00 rsi: 0x0000000000000001 rbp: 0x0000000105b6dfd0 rsp: 0x0000000105b6df50
r8: 0x0000000000000024 r9: 0x0000000000000000 r10: 0x00000001054b2ae8 r11: 0x00000001052ecf28
r12: 0x0000000000000100 r13: 0x0000000000000001 r14: 0x00007fd022829e00 r15: 0x00007fd022848c00
rip: 0x00000001052ecffc rfl: 0x0000000000010246 cr2: 0x0000000000000008
Logical CPU: 0
External Modification Summary:
Calls made by other processes targeting this process:
task_for_pid: 1
thread_create: 0
thread_set_state: 0
Calls made by this process:
task_for_pid: 0
thread_create: 0
thread_set_state: 0
Calls made by all processes on this machine:
task_for_pid: 308
thread_create: 0
thread_set_state: 0
VM Region Summary:
ReadOnly portion of Libraries: Total=147.5M resident=115.1M(78%) swapped_out_or_unallocated=32.4M(22%)
Writable regions: Total=174.9M written=6084K(3%) resident=7420K(4%) swapped_out=0K(0%) unallocated=167.7M(96%)
REGION TYPE VIRTUAL
=========== =======
MALLOC 127.8M
MALLOC guard page 80K
Memory tag=241 136K
Memory tag=243 (reserved) 30.0M reserved VM address space (unallocated)
Memory tag=244 320K
STACK GUARD 56.1M
Stack 16.1M
VM_ALLOCATE 8K
__DATA 12.1M
__IMAGE 528K
__LINKEDIT 53.7M
__TEXT 93.8M
__UNICODE 544K
mapped file 18.6M
shared memory 308K
=========== =======
TOTAL 410.1M
TOTAL, minus reserved VM space 380.1M -
Spotlight reindexing drives when booting from Leopard to Tiger & vice versa
Hi,
I have two HDs, one with Leopard and the other with Tiger. Whenever I boot into the other HD I find that Spotlight re-indexes my two 750GB music & data drives which takes some time. Why is this? Do they use different versions of the index?
It's a bit of a pain as I have to boot into both OS's every day and cannot use Spotlight while the indexing is running and it also slows the system down. I do not want to turn indexing off as I need it during my work.
Any help/ideas?dickie001x wrote:
Hi,
I have two HDs, one with Leopard and the other with Tiger. Whenever I boot into the other HD I find that Spotlight re-indexes my two 750GB music & data drives which takes some time. Why is this? Do they use different versions of the index?
yes, they do.
It's a bit of a pain as I have to boot into both OS's every day and cannot use Spotlight while the indexing is running and it also slows the system down. I do not want to turn indexing off as I need it during my work.
Any help/ideas?
I don't think there is any way around this. may I ask why you have to use both tiger and leopard?
you can try using some spotlight alternatives such as [EasyFind|http://www.versiontracker.com/dyn/moreinfo/macosx/11706] when you are using one of the two OS ( either tiger or leopard) and spotlight for the other os. -
Spotlight mds bringing down system, constantly leaking RAM & disk access
Spotlight is going rampant here.
The mds (metadata server, aka Spotlight) process is constantly accessing the disk and writing some data to it, filling it until there is no space left on the device. I cannot find out what file it is writing to. I've tried with fsevener which sadly didn't help.
mds is also eating up all the CPU cycles it can get leaving my system fully loaded at all times.
The mds process is also taking up inceasingly huge amounts of memory, causing permanent swapping of memory and bringing the system to a grinding halt. (Cache Hits go down below 1%, About 250.000 pageins happen per minute.) Memory Footprint is going up to several hundred MB or real RAM.
$ vm_stat
Mach Virtual Memory Statistics: (page size of 4096 bytes)
Pages free: 53166.
Pages active: 275736.
Pages inactive: 135633.
Pages wired down: 59698.
"Translation faults": 10217862.
Pages copy-on-write: 136166.
Pages zero filled: 5983710.
Pages reactivated: 96772.
Pageins: 1236330.
Pageouts: 77113.
Object cache: 24391 hits of 1183451 lookups (2% hit rate)
(This is 95 minutes after reboot. Only running: Finder, Terminal, LaunchBar, Safari, Mail)
This bahaviour goes until the disk is full and I get a "low disk space" warning. Then mds crashes, the system frees up the (temporary?) files written by the process and also frees the RAM taken up by it. Resulting in even more swapping, as the system tries to page-in other processes now. Subseqently the system launches a new mds process and the game starts over.
Things I've tried to remedy:
Rebuilt spotlight index several times. Including totally deleting the .Spotlight-V100 folder on local volumes. Doesn't help, takes about 16 to 20 hours to rebuild on my machine, so is not a thing one wants to just-try.
Reinstalled 10.5.5 Combo Update, doesn't help. Privileges are repaired.
Turn off spotlight completely: Does indeed stop the madness, but now I cannot find anything on my system. So this is not a solution at all.
I've tried to keep the index small by excluding more and more stuff in the privacy settings of the Spotlight PreferencePane. This doesn't solve the problem either.
My System:
PowerBook G4 1.5GHz
2GB RAM (Maximum) (Tested with ASD ok, Rember ok. Different RAM modules, also ok.)
160GB HD (5GB free) (SMART ok, Blockscan ok, Filesystem ok, File privileges ok)
Mac OS X 10.5.5 (9F33) including Security Update 2008/007 (no further updates available)
Any help or suggestions are welcome. I'm happy to provide any further details you may need.
Best regards
PepiJ D McIninch wrote:
This probably isn't Spotlight so much as one of the index plugins (mdimporters). Spotlight itself is very robust, however, all it takes is a single bad indexing plugin. MDS, basically, identifies a file type and loads in a list of plugins that are registered for that file type and executes a routine in the plugin to grab the metadata. If the plugin is improperly written, it can go haywire.
Thanks for the suggestion, I already had checked that.
I don't have any custom (read non-apple provided) Spotlight or QuickLook Plug-Ins on my system. So it is unlikely that it is related to a custom .mdimporter Plug-In. (Might be a buggy Apple one going rampant though.)
I've personally found Spotlight to be quite a solid technology as well. Just the user interface provided by Apple is terrible and especially useless in the Finder (Taking away functionality, or making it horrific to use since Tiger… but that is another story.)
What was the last application that you installed prior to it going crazy? Perhaps one of the last 2-3...
Failing that, you can wipeout the metadata database for a Volume like so (from Terminal.app):
*sudo mdutil -E /Volumes/yourvolumehere*
... or '/' in place of '/Volumes/...' for the local disk. You can turn off metadata indexing for a volume entirely like so:
As I already said, rebuilding the index from scratch doesn't help. Completely deleting it, and rebuilding doesn't remedy as well.
*sudo lsof | grep mdimporter*
... which might help you understand what's being used to index, and this:
/System/Library/Spotlight/Chat.mdimporter/Contents/MacOS/Chat
/System/Library/Spotlight/iCal.mdimporter/Contents/MacOS/iCal /System/Library/Spotlight/Mail.mdimporter/Contents/MacOS/Mail
Nothing fancy here.
I ran a diff on my daily installation report and it gives me these app, that have been modified (Installed or updated in the last 31 days.)
/Applications/Address Book.app
/Applications/Adium.app
/Applications/AppleScript/Script Editor.app
/Applications/Automator.app
/Applications/Carbon Copy Cloner.app
/Applications/Dashboard.app
/Applications/Dictionary.app
/Applications/DVD Player.app
/Applications/Expose.app
/Applications/Flip4Mac/WMV Player.app
/Applications/iCal.app
/Applications/iChat.app
/Applications/iPhoto.app
/Applications/iSync.app
/Applications/iTunes.app
/Applications/JollysFastVNC.app
/Applications/Mail.app
/Applications/OmniFocus.app
/Applications/Photo Booth.app
/Applications/Preview.app
/Applications/Safari.app
/Applications/Skitch.app
/Applications/Spaces.app
/Applications/StuffIt/StuffIt Expander.app
/Applications/StuffIt 12/StuffIt Expander.app
/Applications/Time Machine.app
/Applications/Utilities/Activity Monitor.app
/Applications/Utilities/Bluetooth File Exchange.app
/Applications/Utilities/ColorSync Utility.app
/Applications/Utilities/Directory Utility.app
/Applications/Utilities/Directory.app
/Applications/Utilities/Disk Utility.app
/Applications/Utilities/Keychain Access.app
/Applications/Utilities/Migration Assistant.app
/Applications/Utilities/Network Utility.app
/Applications/Utilities/Podcast Capture.app
/Applications/Utilities/RAID Utility.app
/Applications/Utilities/Remote Install Mac OS X.app
/Applications/Utilities/Terminal.app
/Applications/Utilities/VoiceOver Utility.app
/Applications/Utilities/X11.app
/System/Library/CoreServices/Apple80211Agent.app
/System/Library/CoreServices/AppleFileServer.app
/System/Library/CoreServices/Automator Launcher.app
/System/Library/CoreServices/Automator Runner.app
/System/Library/CoreServices/AVRCPAgent.app
/System/Library/CoreServices/Bluetooth Setup Assistant.app
/System/Library/CoreServices/BluetoothAudioAgent.app
/System/Library/CoreServices/BluetoothUIServer.app
/System/Library/CoreServices/CCacheServer.app
/System/Library/CoreServices/CoreServicesUIAgent.app
/System/Library/CoreServices/DiskImageMounter.app
/System/Library/CoreServices/Dock.app
/System/Library/CoreServices/File Sync.app
/System/Library/CoreServices/FileSyncAgent.app
/System/Library/CoreServices/Finder.app
/System/Library/CoreServices/Help Viewer.app
/System/Library/CoreServices/Installer.app
/System/Library/CoreServices/Kerberos.app
/System/Library/CoreServices/KerberosAgent.app
/System/Library/CoreServices/loginwindow.app
/System/Library/CoreServices/ManagedClient.app
/System/Library/CoreServices/NetAuthAgent.app
/System/Library/CoreServices/Network Diagnostics.app
/System/Library/CoreServices/Network Setup Assistant.app
/System/Library/CoreServices/OBEXAgent.app
/System/Library/CoreServices/ODSAgent.app
/System/Library/CoreServices/PreferenceSyncClient.app
/System/Library/CoreServices/Problem Reporter.app
/System/Library/CoreServices/RemoteManagement/ARDAgent.app
/System/Library/CoreServices/Screen Sharing.app
/System/Library/CoreServices/Spotlight.app
/System/Library/CoreServices/SystemUIServer.app
/System/Library/CoreServices/VerifiedDownloadAgent.app
As you can see, there is nothing special in there as well. Just Apple Apps, and a few non-suspicious ones from my point of view.
Tom in London wrote:
rather than mess around with all of this and maybe fix it until the next Spotlight problem manifests itself, why not just disable Spotlight with Spotless, and use EasyFind instead? Easyfind finds everything, has more options, is reliable, and doesn't cause problems .... and doesn't eat up any space on your hard drive.
...and doesn't find what I need. Thanks for the suggestions though. As I said, totally disabling Spotlight is not an option. I'll stay far away from mysterious tools, as I know what I am doing in a Terminal.
Best regards
Pepi -
Use realational operators in an SQL query??????
does any one knows how to use realational operators in an SQL query??????
i wud like to do something like
select decode(2<3,sysdate,sydate +1) from dual
but i know decode does not supports relational operators......
thanx and Regards
amytYou can use a CASE statement which does support relational operators, or if you must use DECODE, then you can use something like:
SELECT DECODE(SIGN(2 - 3),-1,sysdate,sysdate - 1)
FROM dual;The SIGN function returns -1 if the expression is < 0, 1 if the expression is > 0 and 0 if the expression is 0. This works for numeric comparisions. You can use the GREATEST or LEAST functions in a similar fashion for character comparisions.
TTFN
John -
ROLLUP AND CUBE OPERATORS IN ORACLE 8I
제품 : PL/SQL
작성날짜 : 2000-06-29
========================================
ROLLUP AND CUBE OPERATORS IN ORACLE 8I
========================================
PURPOSE
ROLLUP 과 CUBE Operator에 대해 설명하고자 한다.
Explanation
ROLLUP operator는 SELECT문의 GROUP BY절에 사용된다.
SELECT절에 ROLLUP 을 사용함으로써 'regular rows'(보통의 select된 data)와
'super-aggregate rows'(총계)을 구할 수 있다. 기존에는 select ... union select
를 이용해 구사해야 했었던 것이다. 'super-aggregate rows'는 'sub-total'
(중간 Total, 즉 소계)을 포함한다.
CUBE operator는 Cross-tab에 대한 Summary를 추출하는데 사용된다. 모든 가능한
dimension에 대한 total을 나타낸다. 즉 ROLLUP에 의해 나타내어지는 item total값과
column total값을 나타낸다.
NULL값은 모든 값에 대한 super-aggregate 을 나타낸다. GROUPING() function은
모든 값에 대한 set을 나타내는 null값과 column의 null값과 구별하는데 쓰여진다.
GROUPING() function은 GROUP BY절에서 반드시 표현되어야 한다. GROUPING()은 모든
값의 set을 표현합에 있어서 null이면 1을 아니면 0을 return한다.
ROLLUP과 CUBE는 CREATE MATERIALIZED VIEW에서 사용되어 질수 있다.
Example
아래와 같이 테스트에 쓰여질 table과 data을 만든다.
create table test_roll
(YEAR NUMBER(4),
REGION CHAR(7),
DEPT CHAR(2),
PROFIT NUMBER );
insert into test_roll values (1995 ,'West' , 'A1' , 100);
insert into test_roll values (1995 ,'West' , 'A2' , 100);
insert into test_roll values (1996 ,'West' , 'A1' , 100);
insert into test_roll values (1996 ,'West' , 'A2' , 100);
insert into test_roll values (1995 ,'Central' ,'A1' , 100);
insert into test_roll values (1995 ,'East' , 'A1' , 100);
insert into test_roll values (1995 ,'East' , 'A2' , 100);
SQL> select * from test_roll;
YEAR REGION DE PROFIT
1995 West A1 100
1995 West A2 100
1996 West A1 100
1996 West A2 100
1995 Central A1 100
1995 East A1 100
1995 East A2 100
7 rows selected.
예제 1: ROLLUP
SQL> select year, region, sum(profit), count(*)
from test_roll
group by rollup(year, region);
YEAR REGION SUM(PROFIT) COUNT(*)
1995 Central 100 1
1995 East 200 2
1995 West 200 2
1995 500 5
1996 West 200 2
1996 200 2
700 7
7 rows selected.
위의 내용을 tabular로 나타내어 보면 쉽게 알 수 있다.
Year Central(A1+A2) East(A1+A2) West(A1+A2)
1995 (100+NULL) (100+100) (100+100) 500
1996 (NULL+NULL) (NULL+NULL) (100+100) 200
700
예제 2: ROLLUP and GROUPING()
SQL> select year, region, sum(profit),
grouping(year) "Y", grouping(region) "R"
from test_roll
group by rollup (year, region);
YEAR REGION SUM(PROFIT) Y R
1995 Central 100 0 0
1995 East 200 0 0
1995 West 200 0 0
1995 500 0 1
1996 West 200 0 0
1996 200 0 1
700 1 1
7 rows selected.
참고) null값이 모든 값의 set에 대한 표현으로 나타내어지면 GROUPING function은
super-aggregate row에 대해 1을 return한다.
예제 3: CUBE
SQL> select year, region, sum(profit), count(*)
from test_roll
group by cube(year, region);
YEAR REGION SUM(PROFIT) COUNT(*)
1995 Central 100 1
1995 East 200 2
1995 West 200 2
1995 500 5
1996 West 200 2
1996 200 2
Central 100 1
East 200 2
West 400 4
700 7
위의 내용을 tabular로 나타내어 보면 쉽게 알 수 있다.
Year Central(A1+A2) East(A1+A2) West(A1+A2)
1995 (100+NULL) (100+100) (100+100) 500
1996 (NULL+NULL) (NULL+NULL) (100+100) 200
100 200 400 700
예제 4: CUBE and GROUPING()
SQL> select year, region, sum(profit),
grouping(year) "Y", grouping(region) "R"
from test_roll
group by cube (year, region);
YEAR REGION SUM(PROFIT) Y R
1995 Central 100 0 0
1995 East 200 0 0
1995 West 200 0 0
1995 500 0 1
1996 West 200 0 0
1996 200 0 1
Central 100 1 0
East 200 1 0
West 400 1 0
700 1 1
10 rows selected.
===============================================
HOW TO USE ROLLUP AND CUBE OPERATORS IN PL/SQL
===============================================
Release 8.1.5 PL/SQL에서는 CUBE, ROLLUP 이 지원되지 않는다. 8i에서는 DBMS_SQL
package을 이용하여 dynamic SQL로 구현하는 방법이 workaround로 제시된다.
Ordacle8i에서는 PL/SQL block에 SQL절을 직접적으로 위치시키는 Native Dynamic SQL
(참고 bul#11721)을 지원한다.
Native Dynamic SQL을 사용하기 위해서는 COMPATIBLE 이 8.1.0 또는 그 보다 높아야
한다.
SVRMGR> show parameter compatible
NAME TYPE VALUE
compatible string 8.1.0
예제 1-1: ROLLUP -> 위의 예제 1과 비교한다.
SQL> create or replace procedure test_rollup as
my_year test_roll.year%type;
my_region test_roll.region%type;
my_sum int;
my_count int;
begin
select year, region, sum(profit), count(*)
into my_year, my_region, my_sum, my_count
from test_roll
group by rollup(year, region);
end;
Warning: Procedure created with compilation errors.
SQL> show errors
Errors for PROCEDURE TEST_ROLLUP:
LINE/COL ERROR
10/8 PL/SQL: SQL Statement ignored
13/18 PLS-00201: identifier 'ROLLUP' must be declared
SQL> create or replace procedure test_rollup as
type curTyp is ref cursor;
sql_stmt varchar2(200);
tab_cv curTyp;
my_year test_roll.year%type;
my_region test_roll.region%type;
my_sum int;
my_count int;
begin
sql_stmt := 'select year, region, sum(profit), count(*) ' ||
'from test_roll ' ||
'group by rollup(year, region)';
open tab_cv for sql_stmt;
loop
fetch tab_cv into my_year, my_region, my_sum, my_count;
exit when tab_cv%NOTFOUND;
dbms_output.put_line (my_year || ' '||
nvl(my_region,' ') ||
' ' || my_sum || ' ' || my_count);
end loop;
close tab_cv;
end;
SQL> set serveroutput on
SQL> exec test_rollup
1995 Central 100 1
1995 East 200 2
1995 West 200 2
1995 500 5
1996 West 200 2
1996 200 2
700 7
PL/SQL procedure successfully completed.
예제 2-1: ROLLUP and GROUPING() -> 위의 예제 2와 비교한다.
SQL> create or replace procedure test_rollupg as
my_year test_roll.year%type;
my_region test_roll.region%type;
my_sum int;
my_count int;
my_g_region int;
my_g_year int;
begin
select year, region, sum(profit),
grouping(year), grouping(region)
into my_year, my_region, my_sum, my_count,
my_g_year, my_g_region
from test_roll
group by rollup(year, region);
end;
Warning: Procedure created with compilation errors.
SQL> show error
Errors for PROCEDURE TEST_ROLLUPG:
LINE/COL ERROR
12/4 PL/SQL: SQL Statement ignored
17/13 PLS-00201: identifier 'ROLLUP' must be declared
SQL> create or replace procedure test_rollupg as
type curTyp is ref cursor;
sql_stmt varchar2(200);
tab_cv curTyp;
my_year test_roll.year%type;
my_region test_roll.region%type;
my_sum int;
my_count int;
my_g_region int;
my_g_year int;
begin
sql_stmt := 'select year, region, sum(profit), count(*), ' ||
'grouping(year), grouping(region) ' ||
'from test_roll ' ||
'group by rollup(year, region)';
open tab_cv for sql_stmt;
loop
fetch tab_cv into my_year, my_region, my_sum, my_count,
my_g_year, my_g_region;
exit when tab_cv%NOTFOUND;
dbms_output.put_line (my_year || ' '||my_region ||
' ' || my_sum || ' ' || my_count ||
' ' || my_g_year || ' ' || my_g_region);
end loop;
close tab_cv;
end;
Procedure created.
SQL> set serveroutput on
SQL> exec test_rollupg
1995 Central 100 1 0 0
1995 East 200 2 0 0
1995 West 200 2 0 0
1995 500 5 0 1
1996 West 200 2 0 0
1996 200 2 0 1
700 7 1 1
PL/SQL procedure successfully completed.
예제 3-1: CUBE -> 위의 예제 3과 비교한다.
SQL> create or replace procedure test_cube as
my_year test_roll.year%type;
my_region test_roll.region%type;
my_sum int;
my_count int;
begin
select year, region, sum(profit), count(*)
into my_year, my_region, my_sum, my_count
from test_roll
group by cube(year, region);
end;
Warning: Procedure created with compilation errors.
SQL> show error
Errors for PROCEDURE TEST_CUBE:
LINE/COL ERROR
10/4 PL/SQL: SQL Statement ignored
13/13 PLS-00201: identifier 'CUBE' must be declared
SQL> create or replace procedure test_cube as
type curTyp is ref cursor;
sql_stmt varchar2(200);
tab_cv curTyp;
my_year test_roll.year%type;
my_region test_roll.region%type;
my_sum int;
my_count int;
begin
sql_stmt := 'select year, region, sum(profit), count(*) ' ||
'from test_roll ' ||
'group by cube(year, region)';
open tab_cv for sql_stmt;
loop
fetch tab_cv into my_year, my_region, my_sum, my_count;
exit when tab_cv%NOTFOUND;
dbms_output.put_line (my_year || ' '||
nvl(my_region,' ') ||
' ' || my_sum || ' ' || my_count);
end loop;
close tab_cv;
end;
Procedure created.
SQL> set serveroutput on
SQL> exec test_cube
1995 Central 100 1
1995 East 200 2
1995 West 200 2
1995 500 5
1996 West 200 2
1996 200 2
Central 100 1
East 200 2
West 400 4
700 7
PL/SQL procedure successfully completed.
예제 4-1: CUBE and GROUPING() -> 위의 예제 4와 비교한다.
SQL> create or replace procedure test_cubeg as
my_year test_roll.year%type;
my_region test_roll.region%type;
my_sum int;
my_count int;
my_g_region int;
my_g_year int;
begin
select year, region, sum(profit),
grouping(year), grouping(region)
into my_year, my_region, my_sum, my_count,
my_g_year, my_g_region
from test_roll
group by cube(year, region);
end;
Warning: Procedure created with compilation errors.
SQL> show error
Errors for PROCEDURE TEST_CUBEG:
LINE/COL ERROR
12/4 PL/SQL: SQL Statement ignored
17/13 PLS-00201: identifier 'CUBE' must be declared
SQL> create or replace procedure test_cubeg as
type curTyp is ref cursor;
sql_stmt varchar2(200);
tab_cv curTyp;
my_year test_roll.year%type;
my_region test_roll.region%type;
my_sum int;
my_count int;
my_g_region int;
my_g_year int;
begin
sql_stmt := 'select year, region, sum(profit), count(*), ' ||
'grouping(year), grouping(region) ' ||
'from test_roll ' ||
'group by cube(year, region)';
open tab_cv for sql_stmt;
loop
fetch tab_cv into my_year, my_region, my_sum, my_count,
my_g_year, my_g_region;
exit when tab_cv%NOTFOUND;
dbms_output.put_line (my_year || ' '||my_region ||
' ' || my_sum || ' ' || my_count ||
' ' || my_g_year || ' ' || my_g_region);
end loop;
close tab_cv;
end;
Procedure created.
SQL> set serveroutput on
SQL> exec test_cubeg
1995 Central 100 1 0 0
1995 East 200 2 0 0
1995 West 200 2 0 0
1995 500 5 0 1
1996 West 200 2 0 0
1996 200 2 0 1
Central 100 1 1 0
East 200 2 1 0
West 400 4 1 0
700 7 1 1
PL/SQL procedure successfully completed.
Reference Ducumment
Note:67988.1Hello,
As previously posted you should use export and import utilities.
To execute exp or imp statements you have just to open a command line interface, for instance,
a DOS box on Windows.
So you don't have to use SQL*Plus or TOAD.
About export/import you may care on the mode, to export a single or a list of Tables the Table mode
is enough.
Please, find here an example to begin:
http://wiki.oracle.com/page/Oracle+export+and+import+
Hope this help.
Best regards,
Jean-Valentin -
Spatial query w/ logical operators in a subquery on Linux using Oracle 1
Hello...
I'm being given XML that I need to parse and create SQL from it. Below my signature is the SQL that I generate (its a simple example) and can be more elaborate due to the logical operators (AND and OR) given in the XML.
The problem that we're seeing is performance-based: when one of the logical operator queries is Spatial-based, like below. Running it in JDBC, the query never returns.
The spatial query just by itself returns ~300 rows (takes approximately 0.2 seconds). The "PERCENTAGE" query by itself returns about ~40000 rows (takes approximately ~.8 seconds).
If we run the query below with 2 non-spatial subqueries, the result returns and performance is very acceptable (~ 0.9 seconds)-- the result set is about 80000 rows.
Thanks,
Jim
=========================
SELECT
COLUMN_WE_WANT , RESULTS
FROM
TABLE_A
WHERE
COLUMN_WE_WANT IN
SELECT
COLUMN_WE_WANT
FROM
TABLE_A
WHERE
SDO_OVERLAPBDYINTERSECT(TABLE_A.MY_SPATIAL_COLUMN,
SDO_GEOMETRY(2003,
4326,
null,
SDO_elem_info_array( 1 , 3 , 1 ),
SDO_ORDINATE_ARRAY( lng_1,lat_1 , lng_2,lat_2 , lng_3,lat_3 , lng_4,lat_4 , lng_1,lat_1 )
) = 'TRUE'
OR
COLUMN_WE_WANT IN
SELECT
COLUMN_WE_WANT
FROM
TABLE_B
WHERE
SOME_PERCENTAGE_RATE_COLUMN < 90
)Its difficult to comment without seeing the execution plan. You should trace this query to get a better idea of exactly what's happening.
Depending on the complexity of the logical operators, I would look at doing this using set operations. So for an OR you might have...
SELECT COLUMN_WE_WANT, RESULTS
FROM TABLE_A
WHERE COLUMN_WE_WANT IN (
SELECT COLUMN_WE_WANT
FROM TABLE_A
WHERE SDO_OVERLAPBDYINTERSECT(TABLE_A.MY_SPATIAL_COLUMN,SDO_GEOMETRY(2003,4326,
NULL, SDO_elem_info_array( 1 , 3 , 1 ),
SDO_ORDINATE_ARRAY( lng_1,lat_1 , lng_2,lat_2 , lng_3,lat_3 , lng_4,lat_4 , lng_1,lat_1 ) )) = 'TRUE'
UNION
SELECT COLUMN_WE_WANT
FROM TABLE_B
WHERE SOME_PERCENTAGE_RATE_COLUMN < 90)For an AND, you would use INTERSECT.
Edited by: Reggie to remove the extra INTERSECT
Maybe you are looking for
-
Quotation Items are not displayed on SRM Web
Hi experts! I did a program to create a quotation based on a Bid invitation. My program creates the document correctly, but, when i try to show the quotation on the browser, the quotation items are not displayed. If I open this same quotation on the
-
Problem in deleting entries from internal table
i am selecting vrgar perio paobjnr belnr gjahr perde budat kndnr artnr frwae kursf rec_waers ka
-
KNA1 Mass Maintenance with a BADI implemented.
Hi Everyone, We have implemented a Customer Master BADI to maintain some additional KNA1 and KNVV fields. when we execute XD99 to mass maintain an SAP field (KNVV-AUFSD)we receive an error "Enter a valid value". When I debug I dsicover that it is att
-
Technical Newbie Need help linking 2 computers with WRT54G
Hi, Please excuse my non-technical language! I have 2 PCs that I would like to connect together so that one can get files from the other and vice versa. I have a broadband modem hooked up to a linksys wrt54g wireless router, and each computer is hook
-
Cannot collect online to get to Kuler colors? Have always been able to in the past.
Cannot collect online to get to Kuler colors? Have always been able to in the past.