Hello! I have a table with image data:
/CREATE TABLE images//
//(//
// id serial,//
// image_data bytea,//
// ...//
//);/
This is function for store image data to file:
/CREATE OR REPLACE FUNCTION write_bytea ( p_data bytea, p_filename text )//
//RETURNS void AS//
//$BODY$//
//DECLARE//
// v_oid oid;//
// v_fdesc integer := 0;//
// v_fsize integer := 0;//
//BEGIN//
// v_oid := lo_create ( -1 );//
// v_fdesc := lo_open ( v_oid, CAST ( X'00020000' AS integer ) );//
// v_fsize := lowrite ( v_fdesc, p_data );//
////
// PERFORM lo_export ( v_oid, p_filename );//
// PERFORM lo_close ( v_fdesc );//
// PERFORM lo_unlink ( v_oid );//
//END//
//$BODY$//
//LANGUAGE plpgsql IMMUTABLE;/
Query for saving image:
/SELECT write_bytea ( i.image_data, id::text || '.jpg' )//
//FROM images i;/
My problem: first 30-40 images (~75 KB for one image) save fast but
saving speed of nextimages slows down and slows down. What is wrong?
P.S. I try use it in pgAdmin and in psql, but problem doesn't disappear.