Giter Site home page Giter Site logo

parallelsql's Introduction

parallelsql

A sql extenstion that parallizes sql queries using dblink

Author: Copyright (c) 2015 Klaus Ackermann [email protected]

Written during the The Eric & Wendy Schmidt Data Science for Social Good Fellowship at University of Chicago 2015.

parllelsql.sql defines a single Postgres function:

SELECT parallelsql
(       'geo',                                  --database
        'tl2',                          		--table
        'map.gid',                              --variable to partition by processes    
        '$STATEMENT',                           --the statement as string to be executed in parallel 
        'tl2_pop_ref',                  		--result table, has to be created first
        'map',                                  --table alias used for split column
        16,                                     --number of cores
        '1=1',                                  --replace string in the query
        500                                     --block size
); 

The function takes a single sql statement and replaces a string in a where condition to execute the query in parallel. Suitable for all queries where the input can be split into sub parts. A block size is specified to reduce the amount of memory required for storing in between results, such as it is common for long running geometric operations using PostGis.

The code is an extension of parsel. However, parallelsql() does not create between results in memory and can therefore make use of database indexes. The block wise load balancing allows to reduce the runtime by querries that otherwise would require a too large cross product internally. Especially in combination with the Postgres LATERAL join feature, the runtime can be reduced.

Benefits and use cases so far:

  • Used on Amazon AWS Postgres instance with 28 cores and PostGIS for distance calculation between 4 Million and 50000 georeferenced points.
  • Calculation of raster summary statistics for world wide population data.
  • Can be run directly from a shell script and does not require a manual Map-Reduce implementation in a programming language.

Example

Under example is a bash script and sql statement for the calculation of summary raster statistics in parallel.

parallelsql's People

Contributors

k1aus avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.