I see only 2 alternatives there, either append text to a blob directly, or append to a text variable and then move it to a blob.
I ran a quick test using both alternatives, and a series of TEXT TO BLOB is more than 10x faster then appending to a text variable and then moving it to a blob. Code is attached. Testing with smaller repeat counts yields basically no difference. With a large repeat count then we are talking about 20ms (blob) against 287ms (text). Running compiled. hth julio > On Aug 1, 2017, at 7:22 AM, David Adams via 4D_Tech <4d_tech@lists.4d.com> > wrote: > > Thanks for the answer! I was not clear in my question :( I'm calling a > command in the PostgreSQL plug-in like this: > > PgSQL Send Copy Data( connection id ; data in a blob ; rowCount ) → > result > > The second argument contains the data you're sending, and it has to be > passed into the plug-in as a BLOB. Presumably, this is because the plug-in > supports very old versions of 4D that had a 32,000 character limit on text > values. My source data consists of strings and longints, but I need to get > it into a BLOB. > > This plug-in command is making it easy to call the Postgres COPY IN > command. That's Postgres' native bulk loader. I'm likely to be transferring > millions of rows at a time, so high-speed bulk loading is of real interest. > These days it's rare that I find the need to worry about optimizing > operations but, in this case, it is necessary. > > So, with that background, I'm asking about the fastest way to load up a > BLOB...if that's even a meaningful question and if anyone has advice. > > Thanks! -- Julio Carneiro jjfo...@gmail.com =============================== C_LONGINT($start;$time1;$time2;$i) C_BLOB($blob1;$blob2) C_TEXT($text) SET BLOB SIZE($blob;0) $start:=Milliseconds For ($i;1;10000) TEXT TO BLOB("abcdefghijklmnopqrstuvwxyz01234567890";$blob1;UTF8 text without length;*) End for $time1:=Milliseconds-$start SET BLOB SIZE($blob2;0) $text:="" $start:=Milliseconds For ($i;1;10000) $text:=$text+"abcdefghijklmnopqrstuvwxyz01234567890" End for TEXT TO BLOB($text;$blob;UTF8 text without length) $time2:=Milliseconds-$start ALERT("Add to Blob:"+String($time1)+"\nAdd to Text:"+String($time2)) ********************************************************************** 4D Internet Users Group (4D iNUG) FAQ: http://lists.4d.com/faqnug.html Archive: http://lists.4d.com/archives.html Options: http://lists.4d.com/mailman/options/4d_tech Unsub: mailto:4d_tech-unsubscr...@lists.4d.com **********************************************************************