This file contains 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
require 'pg_query' | |
pp PgQuery.parse("SELECT * FROM x WHERE y = ?") | |
#<PgQuery:0x007f8cdaaaae10 | |
@parsetree= | |
[{"SELECT"=> | |
{"distinctClause"=>nil, | |
"intoClause"=>nil, | |
"targetList"=> | |
[{"RESTARGET"=> |
This file contains 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
require 'pg_query' | |
pp PgQuery.parse("SELECT 1") | |
#<PgQuery:0x007f8cdaa8f8b8 | |
@parsetree= | |
[{"SELECT"=> | |
{"distinctClause"=>nil, | |
"intoClause"=>nil, | |
"targetList"=> | |
[{"RESTARGET"=> |
This file contains 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
# Copyright (c) 2014 Lukas Fittl <lukas@pganalyze.com> | |
# | |
# Released in the public domain - fork as you wish. | |
require 'rubygems' | |
require 'mixlib/cli' | |
require 'pg' | |
require 'pg_query' | |
require 'curses' |
This file contains 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
AVG | QUERY | |
-------------------------------------------------------------------------------- | |
1.5ms | SELECT "users".* FROM "users" | |
0.1ms | SELECT "users".* FROM "users" WHERE "users"."id" = ? ORDER BY "users"."id" ASC LIMIT ? | |
0.1ms | UPDATE "users" SET "fullname" = $1, "updated_at" = $2 WHERE "users"."id" = ? | |
0.0ms | SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT 1 |
This file contains 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
require 'rubygems' | |
require 'mixlib/cli' | |
require 'pg' | |
require 'curses' | |
class CLIHelper | |
include Mixlib::CLI | |
option :database, | |
short: "-d DATABASE", |
This file contains 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
AVG | QUERY | |
--------------------------------------------------------------------------------- | |
96.5ms | SELECT q.classification, date_part(?, qsh.collected_at) AS collected_at, SUM(qsh.total_time) / SUM(qsh.calls) AS avg FROM query_snapshot_hourlies qsh JOIN queries q ON (qsh.query_id = q.id) WHERE qsh.database_id = ? AND qsh.collected_at BETWEEN ? AND ? AND q.database_id = ? AND NOT truncated GROUP BY q.classification, qsh.collected_at ORDER BY qsh.collected_at | |
87.4ms | SELECT q.id AS query_id, normalized_query, classification, SUM(total_time) AS total_time, SUM(calls) AS calls, SUM(total_time) / SUM(calls) AS avg_time FROM query_snapshot_hourlies qsh JOIN queries q ON (qsh.query_id = q.id) WHERE qsh.database_id = ? AND qsh.collected_at BETWEEN ? AND ? AND q.database_id = ? AND NOT truncated AND (q.classification IS NULL OR q.classification IN (?)) GROUP BY q.id | |
47.9ms | SELECT "schema_indices".* FROM "schema_indices" INNER JOIN "schema_tables" ON "schema_indices"."table_id" = "schema_tables"."id" WHER |
This file contains 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
/* | |
* raw_parser | |
* Given a query in string form, do lexical | |
* and grammatical analysis. | |
* | |
* Returns a list of raw (un-analyzed) parse trees. | |
*/ | |
List * | |
raw_parser(const char *str) | |
{ |
This file contains 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
List *tree; | |
char *str; | |
str = StringValueCStr(input); | |
tree = raw_parser(str); | |
str = nodeToJSONString(tree); | |
// Save stderr for result | |
read(stderr_pipe[0], stderr_buffer, STDERR_BUFFER_LEN); |
This file contains 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
leanstartup.at | |
leanstartupcircle.at | |
hackrails.com | |
seedfinancing.org | |
incubatorlist.com | |
incubatorwiki.com | |
Email lukas@fittl.com or "lfittl" on Skype. |
This file contains 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
#!/bin/bash | |
echo "*** STARTING SYNC `date` ***" >> /root/sync.log | |
/root/fossil/fossil pull -R /root/mongrel2.fossil http://mongrel2.org:44445/ >> /root/sync.log | |
cd /root/mongrel2 | |
/root/fossil/fossil export -R /root/mongrel2.fossil | git fast-import --quiet >> /root/sync.log | |
git push --all origin >> /root/sync.log 2>&1 | |
echo "*** FINISHED SYNC `date` ***" >> /root/sync.log |