This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--sql, args := DB. | |
-- Insect("tab"). | |
-- Columns("b", "c"). | |
-- Values(1, 2). | |
-- Where("d = $1", 3). | |
-- Returning("id", "f", "g"). | |
-- ToSQL() | |
WITH | |
sel AS (SELECT id, f, g FROM tab WHERE (d = $1)), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
nspname || '.' || relname AS "relation", | |
pg_size_pretty (pg_relation_size(C .oid)) AS "size" | |
FROM | |
pg_class C | |
LEFT JOIN pg_namespace N ON (N.oid = C .relnamespace) | |
WHERE | |
nspname NOT IN ( | |
'pg_catalog', | |
'information_schema' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"env":{"GOPATH": "/Users/siesta/go"}, | |
"snippets": [ | |
{ | |
"match": {"global": true}, | |
"snippets": [ | |
{"text": "prl", "title": "fmt.Println(...)", "value": "fmt.Println(\"$1-->\", $1)"}, | |
{"text": "prlpr", "title": "Pretty fmt.Println(...)", "value": "fmt.Printf(\"$1 %# v\", pretty.Formatter($1))"}, | |
{"text": "prf", "title": "fmt.Printf(...)", "value": "fmt.Printf(\"$1 %+v\", $1)\n\n$2"}, | |
{"text": "err", "title": "err clause", "value": "if err != nil {\n\treturn err$2\n}\n$3"}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
pg_size_pretty ( | |
SUM (pg_relation_size(idx)) :: BIGINT | |
) AS SIZE, | |
(ARRAY_AGG(idx)) [ 1 ] AS idx1, | |
(ARRAY_AGG(idx)) [ 2 ] AS idx2, | |
(ARRAY_AGG(idx)) [ 3 ] AS idx3, | |
(ARRAY_AGG(idx)) [ 4 ] AS idx4 | |
FROM | |
( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
T .tablename, | |
indexname, | |
C .reltuples AS num_rows, | |
pg_size_pretty ( | |
pg_relation_size (quote_ident(T .tablename) :: TEXT) | |
) AS table_size, | |
pg_size_pretty ( | |
pg_relation_size ( | |
quote_ident(indexrelname) :: TEXT |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
relname, | |
seq_scan - idx_scan AS too_much_seq, | |
CASE | |
WHEN seq_scan - idx_scan > 0 THEN | |
'Missing Index?' | |
ELSE | |
'OK' | |
END, | |
pg_relation_size (relname :: regclass) AS rel_size, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
iter := collection.Find(nil).Sort("$natural").Tail(5 * time.Second) | |
for { | |
for iter.Next(&result) { | |
fmt.Println(result.Id) | |
lastId = result.Id | |
} | |
if err := iter.Close(); err != nil { | |
return err | |
} | |
if iter.Timeout() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
START place=node:node_auto_index(name = "CoffeeShop1") | |
MATCH place<-[:favorite]-person-[:favorite]->stuff | |
RETURN stuff.name, count(*) | |
ORDER BY count(*) DESC, stuff.name |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
START place=node:node_auto_index(name = "CoffeeShop1") | |
MATCH place-[:tagged]->tag<-[:tagged]-otherPlace | |
RETURN otherPlace.name, collect(tag.name) | |
ORDER BY length(collect(tag.name)) DESC, otherPlace.name |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"regexp" | |
) | |
func main() { | |
//re := regexp.MustCompile("a(x*)b") | |
re := regexp.MustCompile("(buffal|tomat|potat)o$") |