I'm only calling this in the case referenced in the SO question (small
tables for testing). If we do this in production we can `TRUNCATE`.


On Wed, Sep 4, 2013 at 11:18 AM, Frank Farmer <notifications@github.com>wrote:

> In sql/partitioned/stored_procedures.sql:
>
> > +  EXECUTE format('DELETE FROM poky_%I WHERE bucket = %L AND key = %L', b, b, k);
> > +  GET DIAGNOSTICS _rows = ROW_COUNT;
> > +  RETURN _rows;
> > +END;
> > +$$
> > +LANGUAGE plpgsql;
> > +
> > +
> > +-- delete all of the keys in a bucket.
> > +-- warning, this will create a lot of cruft in the table if the bucket is large
> > +CREATE OR REPLACE FUNCTION purge_bucket(b TEXT) RETURNS INTEGER AS
> > +$$
> > +DECLARE
> > +  _rows INTEGER;
> > +BEGIN
> > +  EXECUTE format('DELETE FROM poky_%I', b);
>
>  DELETE FROM table; is very cheap for small tables with no f/k refs
>
> If we were working with small tables, and doing this frequently, that'd be
> something to worry about.
>
> These tables are often multiple GB, in which case TRUNCATE wins every time.
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/drsnyder/poky/pull/21/files#r6161864>
> .
>



-- 
http://damonsnyder.net