Posts

Queries

Why does count, min, max explain plan show a sort operation? SELECT count(1) FROM foo; SELECT min(x) FROM foo; Count/min/max/etc. will always show a sort operation in the explain plan because they are aggregate functions with an implicit group by even if they return only one row. They share the common code path even though it is effectively a no-op. Faster count avoiding full index/table scan with sampling: 1% sample SELECT COUNT(1) * 100 FROM  SAMPLE (1); Find ALL FKs to a table: SELECT owner,   constraint_name,   constraint_type,   table_name,   r_owner,   r_constraint_name FROM all_constraints WHERE constraint_type  ='R' AND r_constraint_name IN   (SELECT constraint_name   FROM all_constraints   WHERE constraint_type IN ('P','U')   AND table_name         ='DATA_AUDIT'   );

Power down display

http://ubuntuforums.org/showthread.php?t=608212 http://www.x.org/releases/X11R7.6/doc/libXext/dpmslib.html

Compiz script cube rotation

http://sfyang-en.blogspot.com/2008/02/rotate-cube-in-compiz-with-wmctrl.html Initiate rotate from command line, Exc exits rotation: dbus-send --type=method_call --dest=org.freedesktop.compiz /org/freedesktop/compiz/rotate/allscreens/initiate_button org.freedesktop.compiz.activate string:'root' int32:`xwininfo -root | grep id: | awk '{ print $4 }'`

Split string every nth char

http://stackoverflow.com/questions/2297347/splitting-a-string-at-every-n-th-character String[] tokens = s . split ( "(?<=\\G...)" ) The regex  (?<=\G...)  matches an empty string that has the  last match  ( \G ) followed by  three characters  ( ... )  before  it ( (?<= ) )

Oracle

Flushing caches for testing: ALTER SYSTEM FLUSH BUFFER_CACHE; alter system flush shared_pool; Finding unusable, invalid, and disabled indexes: select owner, index_name from dba_indexes where status='UNUSABLE'; select index_name, status from dba_indexes where status = 'DISABLED'; select owner,table_name,index_name,last_analyzed,status from dba_indexes where status != 'VALID'; Rebuild index: alter index XXX.XXX rebuild;   BEGIN     FOR i IN       (SELECT index_name         FROM  dba_indexes          WHERE  status != 'VALID'                         AND  table_name=' ')     LOOP       EXECUTE immediate 'alter index ' || i.index_name || 'rebuild';     END LOOP;   END;   / Compute schema statistics: A...

Oracle Partitioning

Oracle 11g R2 supports automatic partition management. Creating Partitions White paper

Mounting Red Hat LVM on Ubuntu

$ sudo apt-get install lvm2 $ sudo modprobe dm-mod Scan your system for LVM volumes: $ sudo vgscan Activate the volume: $ sudo vgchange -ay vg_troylt Find the logical volume under LV column: $ sudo lvs Example: LG VG ... lv_root vg_troylt ... Create a mount point for that volume: $ sudo mkdir /mnt/rh_linux Mount it: $ sudo mount /dev/vg_troylt/lv_root /media/rh_linux -o ro,user Credit