Before beginning to test the iOS autorenewing purchases I need to prepare my server database. My question is simple. I just wanna know what size I should make the varchar field in my database.
-
4Simply use TEXT, then it will always fit :) – Anne Mar 28 '11 at 19:59
-
I will need to recommend changes to a current API that's fully defined so need to get more specific. – 3advance Mar 30 '11 at 14:44
-
Better use MEDIUMTEXT. I used TEXT but didnt fit well at one point. – Abhijith Apr 25 '19 at 14:19
I was using a varchar (4096) to store my base64 encoded receipts.
But to be honest, I couldn't find anything regarding receipt length on the official documentation (or anywhere else). The only thing I did find on Apple's docs was that the receipt content/format is subject to change:
The contents and format of the store receipt is private and subject to change. Your application should not attempt to parse the receipt data directly. Use the mechanism described here to validate the receipt and retrieve the information stored inside it.
So probably going for text instead of varchar really is the best option.
-
3I store them on the server. My receipt size is
6340
bytes long (Mac App Store, with subscriptions). – Erik Aigner Jun 23 '15 at 13:38 -
-
receipt-data
could grow to be much larger due to it containing older subscription information.
In practice, typical size is probably under 10KB. But I've seen receipt-data as large as over 500KB in automated testing, due to repeatedly creating new subscriptions.
It's better to use varchar(max) or text where it's not bounded.
In MySQL, it's safe to use MEDIUMTEXT which has capacity 16 MB.
We were using TEXT but didn't fit well at one point.
TEXT has only 64kb capacity but it's more likely that receipt size will be morethan this after repeated transactions. I only observed this after many transaction in sandbox mode.
TINYTEXT: 255 characters - 255 B
TEXT 65,535 bytes - 64kb
MEDIUMTEXT: 16,777,215 - 16 MB
GBTEXT: 65,535 characters - 64 MB
KBLONGTEXT: 4,294,967,295 characters - 4 GB
-
Closest to MySQL MEDIUMTEXT(16,777,215 characters) in SQL Server is nvarchar(MAX) 536,870,912 characters – Kishan Vaishnav Apr 29 '20 at 10:19
After doing some simple math I figured out it was safe to use MEDIUMTEXT as each receipt size grows by the factor of ~2KB/transaction and so you would need more than 800 transactions to max out the size. Thus, considering a very safe use span of 10 years it'd require more than 80 transactions a month or roughly 7-8 transactions every month which won't be the case for most use-cases.
May be use jsonb
to store the base64. It can hold as long as 1MB.
-
1