Posts

Showing posts from February, 2018

SQL Joins

Image
Joins are used to combine rows from two or more tables based on related columns between them. Joins allow you to retrieve data from multiple tables simultaneously, enabling you to create complex queries that fetch data from different sources. There are different types of joins in SQL, including: INNER JOIN Returns only the rows that have matching values in both tables based on the specified join condition. It discards non-matching rows from both tables. Example:           create table t1(x int); insert into t1 values(1); insert into t1 values(1); insert into t1 values(0); create table t2(y int); insert into t2 values(0); insert into t2 values(1); insert into t2 values(1);           select * from t1 inner join t2 on t1.x = t2.y Output: 2. LEFT JOIN (or) LEFT OUTER JOIN Returns all the rows from the left (or first) table and the matching rows from the right (or second) table. If there is no match, NULL values are

Postgresql CStore Implementation

Cstore is a foreign data wrapper for postgres used for the analytic workloads . Cstore highly compress and stores the data in the columnar format. The following are the steps to install and implement cstore in the postgresql 9.6 in ubuntu. > sudo apt-get install \ git \ libpq-dev \ libprotobuf-c0-dev \ make \ postgresql-server-dev-9.6 \ protobuf-c-compiler > sudo apt-get install gcc > rm -rf cstore_fdw/ > git clone https://github.com/citusdata/cstore_fdw.git > cd cstore_fdw > make -j8 && \ sudo make install > sudo su - postgres > createdb sample; After the installation , in postgresql.conf specify shared_preload_libraries = 'cstore_fdw' > CREATE EXTENSION cstore_fdw; > CREATE SERVER cstore_server FOREIGN DATA WRAPPER cstore_fdw;