[postgis-users] jdbc, bytea for the write side

Andrea Aime andrea.aime at aliceposta.it
Sun Jul 4 23:16:16 PDT 2004


Alle 05:22, lunedì 5 luglio 2004, David Blasby ha scritto:
> ByteA is binary compatible with the postgis type, so you should just
> be able to create a "binary compatible" 'NULL' cast for it.
>
> I think something like "CREATE CAST (BYTEA AS
> WKB)   WITHOUT FUNCTION AS IMPLICIT ;" should do the trick.
>
> This is only available in recent postgresql versions.
>
> You can do it in older versions easily, too.
>
> Unfortunately, I'm no longer working at Refractions and I havent got a
> system setup at home yet; I'm unable to test.
>
> I believe you can (as funny as it sounds), use the "WKBtoBYTEA"
> function since its a do-nothing function.
>
> CREATE FUNCTION wkb(bytea)
>        RETURNS geometry
>        AS '@MODULE_FILENAME@','WKBtoBYTEA'
>        LANGUAGE 'C' WITH (iscachable,isstrict);
>
> So instead of using "bytea2wkb()" you can use "wkb(<bytea>)".

Thank you, I'll try it out

> If this works, have strk commit the change.
>
> Have you checked to see whats actually being sent between geotools and
> Postgis?  If I remember the SQL standard, bytea is sent as strings
> like '0001001001000111001' - you could be sending 8* as much data as
> you're expecting.  (This is assuming a text, NOT binary, cursor).

Funny, since the same "read 20000 geometries and convert to JTS" sintetic test 
went down from 19 secs, using the WKB format, to 12, using  
bytea(asBinary(...)). I did not check, I kind of remember from the manual 
that effectively special chars such as the 0 gets turned into 4 bytes, but 
the others remain pretty the same. Hum, I guess I should try with more 
variations in the data read for the test...

Thanks again
Best regards
Andrea Aime



More information about the postgis-users mailing list