go-ora icon indicating copy to clipboard operation
go-ora copied to clipboard

Stream LOB

Open bersace opened this issue 6 months ago • 6 comments

Hi,

Thanks for go-ora !

I need to handle LOB by chunk of data. It seems go-ora does not expose io.Reader API for Lob. What do you think of this feature ? Would you accept a patch in this direction ? Do you have clues on this issue ?

Regards, Étienne

bersace avatar Jun 25 '25 12:06 bersace

A proposal would bo to hijack lob.data using a new API lob.Hijack(f io.Writer). What do you think of this ?

bersace avatar Jun 25 '25 16:06 bersace

A proposal would bo to hijack lob.data using a new API lob.Hijack(f io.Writer). What do you think of this ?

I dug a but. This is not the right path. Need to investigate this more. Clues welcome.

bersace avatar Jun 26 '25 09:06 bersace

Hi @bersace I will investigate how to implements and inform you

sijms avatar Jun 28 '25 20:06 sijms

For now, I investigate streaming LOB using DBMS_LOB.SUBSTR. This streams by chunk of 4k (BLOB) or 2k (CLOB). Such small chunk has overhead.

Actually, pgx wraps Postgres LO API in a io.ReadWriter struct. This is easy because Postgres LO has an OID. So the app queries de OID and execute de streaming API for each OID.

It seems that we can't apply such easy logic with ORA.

bersace avatar Jun 30 '25 07:06 bersace

Using DBMS_LOB.SUBSTR is extremly slow. I dream of a way to stream chunk of data using io.Writer, maybe using a specific API. Something like:

var lob ora.LOB
row.Scan(&lob)
lob.Read(buffer) // stream a chunk of data.

bersace avatar Aug 05 '25 09:08 bersace

@sijms at oracle protocol level, how does Oracle send data ? What are the network messages ? How many ? Which size ? Which order ?

bersace avatar Aug 05 '25 09:08 bersace