Re: obtain a BLOB size without fetching the whole thing?
Re: obtain a BLOB size without fetching the whole thing?
- Subject: Re: obtain a BLOB size without fetching the whole thing?
- From: Aaron Rosenzweig via Webobjects-dev <email@hidden>
- Date: Wed, 25 Jun 2025 11:15:46 -0400
Yes Samuel is right, a derived entity will help but it is only part of the
answer.
When an EO is fetched, all of it is fetched. In this case the blob plus the
derived attribute so it defeats the purpose. You haven’t avoided fetching the
blob.
I’m going to give your EO a name, let’s call it “DataAttachment.plist” with
schema table “data_attachment”
Let’s say right now you have two attributes:
1) id (the PK)
2) data (the BLOB)
Let’s now make two EOs:
1) DataAttachment.plist
2) DataAttachmentFull.plist
They both map to the same schema table “data_attachment”
But now the original “DataAttachment.plist” will lose the blob and gain the
derived plus have an optional FK to the “full” eo:
1) id - the PK
2) dataSize - derived attribute of octet_length(data)
3) optional toOneRelationship named “full” that uses the id (pk) but points to
DataAttachmentFull.plist
And then “DataAttachmentFull.plist” will be:
1) id (the PK)
2) data (the BLOB)
So in this way, you’ll have minimal refactor of your code. Most places will
still use and fetch “DataAttachment” but when you actually need the blob you’ll
have to traverse the to-one relationship. Those are the places in code you’ll
fix. Your app will be speedier since you aren’t fetching the blob until you
need it.
> On Jun 24, 2025, at 7:40 PM, Samuel Pelletier via Webobjects-dev
> <email@hidden> wrote:
>
> Hi OC,
>
> Without more details about your schema and needs, the only thing I see is
> maybe a derived attribute on an entity may be a starting point.
>
> Regards,
>
> Samuel
>
>> Le 24 juin 2025 à 17:33, ocs--- via Webobjects-dev
>> <email@hidden <mailto:email@hidden>> a
>> écrit :
>>
>> Great, thanks! Works like a charm :)
>>
>> If there is a trick to do this at a higher EOF level, would be nice, but if
>> there's none, this solves my problem all right. Thanks again!
>>
>> All the best,
>> OC
>>
>>> On 24. 6. 2025, at 23:25, Amedeo Mantica <email@hidden> wrote:
>>>
>>> try something like this...
>>> (raw SQL)
>>>
>>> SELECT id, OCTET_LENGTH(blob_col) AS blob_size_bytes FROM my_table;
>>>
>>>> Il giorno 24 giu 2025, alle ore 21:27, ocs--- via Webobjects-dev
>>>> <email@hidden> ha scritto:
>>>>
>>>> Hi there,
>>>>
>>>> the subject says it all. I've got a FS which reads in some columns set up
>>>> through setRawRowKeyPaths. The entity contains also a BLOB column which
>>>> can be rather big. Is there a trick to get its size only in the result
>>>> dictionaries, without actually fetching the data?
>>>>
>>>> If db-specific, with FrontBase.
>>>>
>>>> Thanks a lot!
>>>> OC
>>>> _______________________________________________
>>>> Do not post admin requests to the list. They will be ignored.
>>>> Webobjects-dev mailing list (email@hidden)
>>>> Help/Unsubscribe/Update your Subscription:
>>>>
>>>> This email sent to email@hidden
>>>
>>
>> _______________________________________________
>> Do not post admin requests to the list. They will be ignored.
>> Webobjects-dev mailing list (email@hidden)
>> Help/Unsubscribe/Update your Subscription:
>>
>> This email sent to email@hidden <mailto:email@hidden>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Webobjects-dev mailing list (email@hidden
> <mailto:email@hidden>)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden <mailto:email@hidden>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden