开发者

PostgreSQL 8.3 data types: xml vs varchar

开发者 https://www.devze.com 2022-12-17 05:39 出处:网络
There\'s xml data type in Postgres, I never used it before so I\'d like to hear opinions. Downsides and upsides vs using regular varchar (or Text) column to store xml.

There's xml data type in Postgres, I never used it before so I'd like to hear opinions. Downsides and upsides vs using regular varchar (or Text) column to store xml.

The text I'm going to store is xml, well-formed, UTF-8. No need to search by it (I've read searching by xml is slow).

This XML actually is data prepared for PDF generation with Apache FOP. XML can be generated dynamically from data found elsewhere (other Postgres tables), it's stored as is only so 开发者_如何学Cthat I won't need to generate it twice. Kinda backup#2 for already generated PDF documents.

Anything else to know? Good practices, performance, maintenance, etc?


XML differs from TEXT only logically: first, the input is checked for validity, second, the XML type lack comparison operators so you cannot index it, compare, use in UNION or DISTINCT etc.

If you are not going to search against it using indexes and want to make an extra check for validity, then use XML safely.


I haven't compared performance, but a good thing with using the XML-type is that you'll get the server to ensure the XML is well-formed. Perhaps later on you'll have use for any of the many XML-functions available.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号