Showing posts with label postgre. Show all posts
Showing posts with label postgre. Show all posts

Oct 25, 2016

Compile and run Postgres with debug symbols

cd SOURCE_DIR
mkdir $HOME/root/postgres_git
./configure --enable-cassert --enable-debug CFLAGS="-ggdb -Og -g3 -fno-omit-frame-pointer" --prefix=$HOME/root/postgres_git
make
make install


sudo service postgresql stop
cd /home/seaside/root/postgres_git/bin
mkdir -p ../usr/local/pgsql/data
sudo chown postgres ../usr/local/pgsql/data
sudo su - postgres
./initdb -D ../usr/local/pgsql/data
postgres -D ../usr/local/pgsql/data > ../usr/local/pgsql/data/logfile 2>&1 &
./createdb test
./psql test
test=# SELECT pg_backend_pid();


sudo gdb -p 2466
Developer_FAQ Install

Jun 10, 2013

PostgreSQL

http://www.postgresql.org/docs/9.4/static/app-psql.html

Aug 22, 2012

pgfouine

http://pgfouine.projects.postgresql.org/reports.html -  is a PostgreSQL log analyzer used to generate detailed reports from a PostgreSQL log file. pgFouine can help you to determine which queries you should optimize to speed up your PostgreSQL based application.

Jul 11, 2012

Pgtune - postgresql.conf tuning wizard

pgtune takes the wimpy default postgresql.conf and expands the database server to be as powerful as the hardware it's being deployed on
sudo apt-get install pgtune
pgtune -i /etc/postgresql/8.4/main/postgresql.conf -T Web -c 100 -M 96000000

Jun 20, 2011

PostgreSQL

#dump 
# http://stackoverflow.com/questions/2893954/how-to-pass-in-password-to-pg-dump
pg_dump -U db_user db_name | gzip > dump.sql.gz
gunzip dump.sql.gz
psql -U db_user db_name -f -  < dump.sql

#create
#grant usage on *.* to uuuu@localhost identified by 'pppp';
grant all privileges on database DB_NAME to USER_NAME;

#priveleges
sudo vi /etc/postgresql/8.4/main/pg_hba.conf

local   all         postgres                          trust

#Show all tables
\dt
# create user
createuser -U postgres -P -S -D -R -e username

# create db
createdb -U postgres -E UTF8 -T template0 -e -O username database_name

Watch what SQL queries Dango produces

from django.db import connection
print connection.queries
print connection.queries[-1]['sql']

Or in Django >= 1.3
import logging
l = logging.getLogger('django.db.backends')
l.setLevel(logging.DEBUG)
l.addHandler(logging.StreamHandler())

Using tshark
sudo tshark -Tfields -e mysql.query -i any -R 'mysql.query'
mysql -h 127.0.0.1 -u root -p