| Models | Examples |
|---|---|
| Display ads | Yahoo! |
| Search ads |
Hey! I saw this has been indexed by the search engines. It is a first draft of a post I ended up publishing on my blog at: Scaling PostgreSQL With Pgpool and PgBouncer
Thanks for stopping by!
Replace a live table with DROP TABLE/ALTER TABLE. Suppose you are re-populating a read-only table that is live, so you don't want to drop the indexes or otherwise have no availability. What I do is create a new table based on the first, populate it (with COPY and no indexes), then drop the main table and alter the new table to make it named the first. Minimal downtime, e.g.:
CREATE TABLE table2 AS SELECT * FROM table LIMIT 1;
DELETE FROM table2
COPY table2 FROM '/tmp/path/to/file.txt';
CREATE INDEX blah2;
VACUUM ANALYZE VERBOSE table2;
ALTER TABLE table RENAME TO table3;
ALTER INDEX blah RENAME TO blah3;| indisready = false | |
| update pg_index set indisvalid = false where indexrelid = 'test_pkey'::regclass |
Simply put, destructuring in Clojure is a way extract values from a datastructure and bind them to symbols, without having to explicitly traverse the datstructure. It allows for elegant and concise Clojure code.
| (defn extract-from-urls | |
| "Takes a directory of tabbed files where URLs are the second field | |
| (after UUID), fetches xhtml either from | |
| dcache or the local cache (depending on doc/*use-local-cache*), | |
| runs all extractors on the xhtml, | |
| and writes JSON strings with extractor name/values and URL to json- | |
| dir. | |
| URLs with parse errors are written to parse-error-dir. | |
| URLs not in dcache are written to cache-miss-dir. | |
| Other errors are written to trap-dir. |
| def can(n,m): return n%m==0 | |
| for i in range(1,100): | |
| if can(i,3) and can(i,5): | |
| print "FizzBuzz",i | |
| elif can(i,3): | |
| print "Fizz",i | |
| elif can(i,5): | |
| print "Buzz",i | |
| def swap(i, j): | |
| sqc[i], sqc[j] = sqc[j], sqc[i] | |
| def heapify(end,i): | |
| l=2 * i + 1 | |
| r=2 * (i + 1) | |
| max=i | |
| if l < end and sqc[i] < sqc[l]: | |
| max = l | |
| if r < end and sqc[max] < sqc[r]: |
| for i in range(len(source)): | |
| mini = min(source[i:]) | |
| print "ITER", mini, source | |
| min_index = source[i:].index(mini) | |
| source[i + min_index] = source[i] | |
| source[i] = mini |
| def qsort(arr): | |
| print "ALL", arr | |
| if len(arr) <= 1: | |
| return arr | |
| else: | |
| left = qsort([x for x in arr[1:] if x<arr[0]]) | |
| middle = [arr[0]] | |
| right = qsort([x for x in arr[1:] if x>=arr[0]]) | |
| print "LMR", left, middle, right | |
| return left + middle + right |