Query Optimization - Equality VARCHAR vs Numeric Equality

I have a large SQL Server database with approximately 40 columns and hundreds of millions of rows.

This table should be free in the schema, so I have many columns like VARCHAR (MAX), even if it can be BIGINT, DATETIME, INT, etc. Does it affect time / performance requests? for example will

SELECT TOP 100 * FROM CustomerId = 34343

will be faster than

SELECT TOP 100 * FROM CustomerId = '34343'

? If so, how much faster?

But what if I use VARCHAR (MAX) instead of a fixed length VARCHAR. What about other databases like mySQL etc. In this respect?

+3
source share
3 answers

, , . , , , . , , . . .

+3

, INT VARCHAR (MAX) . .

, VARCHAR(MAX) - , !

:

- , VARCHAR (MAX) - , ...

+2

, VARCHAR (MAX) VARCHAR.. , mySQL .. ?

  • PostgreSQL VARCHAR(n) TEXT CHECK(LENGTH(Column) <= n). .
  • SQLite VARCHAR.
  • MS SQL Server, , VARCHAR(MAX), .
+1

Source: https://habr.com/ru/post/1758672/


All Articles