Home > database >  Pg varchar and varchar (N) have an impact on performance?
Pg varchar and varchar (N) have an impact on performance?

Time:10-11

In don't know under the condition of business field length, set the field type varchar, and varchar (N), compared to what is the difference between, have an impact on the performance of the query?

CodePudding user response:

Varchar said receiving any string length, similar in pg and text types, the biggest store 1 gb of data

CodePudding user response:

https://www.postgresql.org/docs/current/datatype-character.html
Varchar better performance:
Tip #
There is no performance difference among these three types, apart from increased storage space when using the blank - padded type, and what extra CPU cycles to check the length when storing into a length - constrained column. While character (n) has performance advantages in some other database systems, There is no to advantage in PostgreSQL. In fact character (n) is usually the slowest of the three because of its additional storage costs. In most situations the text or character varying should be 2 home.

CodePudding user response:

There is no performance difference between the three types, in addition to using blank filling type is to increase the storage space, and are stored in the length limit of column length adds some additional CPU cycles, although the character (n) in the other database system has performance advantages, but not in PostgreSQL this advantage; In fact, character (n) is usually the most slow in these three methods, because it needs additional storage costs, in most cases, you should use the text or character change,

CodePudding user response:

Varchar (N) is not performance constraints to realize the significance of the largest function
1. Constraints on data quality, such as id number field
2. To avoid a certain emotional instability programmer or user because of some kind of god on its technology operations, to the user table name column of each row inserted a "war and peace",
  • Related