Tag

VARCHAR

1 views collected around this technical thread.

Architect
Architect
May 17, 2025 · Databases

Storing 2 Billion Phone Numbers: Why VARCHAR(20) Is Preferable to INT/BIGINT

The article explains why using a VARCHAR(20) column to store billions of phone numbers is safer and more flexible than INT or BIGINT, covering range limits, data integrity, query convenience, interview expectations, and common pitfalls such as insufficient field length, charset issues, missing indexes, and lack of encryption.

BIGINTData IntegrityDatabase Design
0 likes · 10 min read
Storing 2 Billion Phone Numbers: Why VARCHAR(20) Is Preferable to INT/BIGINT
macrozheng
macrozheng
May 8, 2025 · Databases

Why Storing 2 Billion Phone Numbers Requires VARCHAR(20) Over INT: Interview Insights

The article examines an interview question about storing 2 billion phone numbers, explains why int cannot hold 11‑digit numbers, advocates using VARCHAR(20) for flexibility and data integrity, and outlines common pitfalls and best practices for database design.

BIGINTDatabase DesignMySQL
0 likes · 8 min read
Why Storing 2 Billion Phone Numbers Requires VARCHAR(20) Over INT: Interview Insights
Java Tech Enthusiast
Java Tech Enthusiast
Apr 30, 2025 · Databases

Storing 2 Billion Phone Numbers: Int vs String, Schema Design and Pitfalls

When designing a schema for two‑billion phone numbers, use a VARCHAR(20) column with utf8mb4 Unicode, a unique index, and proper validation/encryption rather than a 32‑bit INT, because strings preserve leading zeros, international prefixes, extensions, and support business extensibility, fault tolerance, and future changes.

BIGINTDatabase DesignInterview
1 likes · 7 min read
Storing 2 Billion Phone Numbers: Int vs String, Schema Design and Pitfalls
macrozheng
macrozheng
Jan 22, 2025 · Databases

Do Varchar Lengths Really Impact MySQL Storage and Query Performance?

This article experimentally investigates whether the length of VARCHAR columns (e.g., 50 vs 500) affects MySQL storage size and query performance, covering table creation, bulk data insertion, storage queries, index and full‑table scans, and explains the underlying reasons for any differences observed.

Database DesignMySQLPerformance
0 likes · 10 min read
Do Varchar Lengths Really Impact MySQL Storage and Query Performance?
Architecture Digest
Architecture Digest
Dec 15, 2024 · Databases

Impact of VARCHAR Length on MySQL Storage and Query Performance

This article investigates whether the declared length of VARCHAR columns (e.g., VARCHAR(50) vs VARCHAR(500)) affects MySQL storage size and query performance by creating two tables, inserting one million rows, measuring disk usage, and benchmarking various SELECT and ORDER BY operations.

DatabaseMySQLPerformance
0 likes · 10 min read
Impact of VARCHAR Length on MySQL Storage and Query Performance
Java Tech Enthusiast
Java Tech Enthusiast
Dec 13, 2024 · Databases

Impact of VARCHAR Length on MySQL Storage and Query Performance

Testing shows that VARCHAR(50) and VARCHAR(500) occupy identical storage, yet while simple lookups perform similarly, sorting on the longer column triggers disk‑based mergesort and can be several times slower, demonstrating that excessive VARCHAR length harms query performance without saving space.

MySQLPerformanceSQL
0 likes · 10 min read
Impact of VARCHAR Length on MySQL Storage and Query Performance
Aikesheng Open Source Community
Aikesheng Open Source Community
May 7, 2024 · Databases

Why Expanding a MySQL VARCHAR Column from 63 to 64 Characters Takes Much Longer

The article investigates why altering a MySQL VARCHAR column from a length that fits within 255 bytes to one that exceeds this limit (e.g., VARCHAR(63) to VARCHAR(64) in utf8mb4) triggers a costly copy operation, analyzes the storage mechanics, reproduces the issue, and provides practical recommendations to avoid performance penalties.

Database AdministrationMySQLPerformance
0 likes · 13 min read
Why Expanding a MySQL VARCHAR Column from 63 to 64 Characters Takes Much Longer
Aikesheng Open Source Community
Aikesheng Open Source Community
Jan 30, 2024 · Databases

Troubleshooting VARCHAR Column Expansion Issues with MySQL Online DDL

This article analyzes why ALTER TABLE operations that extend VARCHAR columns sometimes fail in MySQL, explains the underlying Online DDL constraints, presents several real‑world problems such as default‑value handling, indexed columns, and hidden table‑rebuild quirks, and offers practical solutions for each case.

ALTER TABLEDatabase AdministrationMySQL
0 likes · 17 min read
Troubleshooting VARCHAR Column Expansion Issues with MySQL Online DDL
IT Services Circle
IT Services Circle
May 29, 2023 · Databases

Storing IPv4 Addresses in MySQL: Choosing the Optimal Data Type

The article explains why storing IPv4 addresses as VARCHAR is suboptimal, demonstrates that a 32‑bit unsigned INT perfectly fits an IPv4 address, compares storage size and query performance, and shows how to use MySQL's inet_aton and inet_ntoa conversion functions.

IP addressIntegerMySQL
0 likes · 6 min read
Storing IPv4 Addresses in MySQL: Choosing the Optimal Data Type
Top Architect
Top Architect
Feb 16, 2022 · Databases

Understanding InnoDB Storage Engine: Page Size, Row Format, and Varchar Limits

This article explains how InnoDB stores data on disk, the role of 16 KB pages in read/write operations, the dynamic row format’s length and NULL lists, overflow handling, and why varchar columns are limited to 16 383 characters under utf8mb4, illustrated with SQL examples.

Database StorageInnoDBMySQL
0 likes · 15 min read
Understanding InnoDB Storage Engine: Page Size, Row Format, and Varchar Limits
Top Architect
Top Architect
Feb 3, 2022 · Databases

Understanding InnoDB Storage Engine: Page Size, Row Format, and VARCHAR Limits

This article explains how InnoDB stores data on disk using 16 KB pages, describes the dynamic row format and its handling of variable‑length columns such as VARCHAR, and clarifies why MySQL limits VARCHAR to a maximum of 16 383 characters under utf8mb4.

Database StorageInnoDBMySQL
0 likes · 15 min read
Understanding InnoDB Storage Engine: Page Size, Row Format, and VARCHAR Limits
Top Architect
Top Architect
Sep 19, 2021 · Databases

Why Store IPv4 Addresses as UNSIGNED INT in MySQL Instead of VARCHAR

The article explains that using a 32‑bit UNSIGNED INT to store IPv4 addresses in MySQL saves space, improves index and range‑query performance, and provides built‑in conversion functions, while also noting readability drawbacks and offering Java utilities for manual conversion.

INET_ATONIP address storageMySQL
0 likes · 6 min read
Why Store IPv4 Addresses as UNSIGNED INT in MySQL Instead of VARCHAR
Top Architect
Top Architect
Jul 5, 2021 · Databases

MySQL Implicit Type Conversion Leads to Unexpected Query Results

This article explains how MySQL implicitly converts mismatched column types—such as comparing a VARCHAR column with a numeric literal—into floating‑point numbers, causing seemingly equal values to match, losing index usage, and potentially producing incorrect query results.

Floating PointMySQLType Conversion
0 likes · 7 min read
MySQL Implicit Type Conversion Leads to Unexpected Query Results
Aikesheng Open Source Community
Aikesheng Open Source Community
Dec 8, 2020 · Databases

Understanding MySQL Online DDL for VARCHAR Column Size Changes and In‑Place vs Copy Operations

The article explains how MySQL's Online DDL handles VARCHAR column expansions, demonstrates performance differences across character sets using sysbench, and clarifies why certain size changes trigger in‑place alterations while others require full table copies, providing practical guidance for DBAs.

InnoDBMySQLVARCHAR
0 likes · 9 min read
Understanding MySQL Online DDL for VARCHAR Column Size Changes and In‑Place vs Copy Operations
Aikesheng Open Source Community
Aikesheng Open Source Community
Feb 26, 2020 · Databases

Understanding MySQL Row Size Limits and the Maximum Number of TEXT Columns

This article explains MySQL's row size restrictions, the differences between server and InnoDB limits, how VARCHAR and TEXT columns affect those limits, and demonstrates through calculations and tests the maximum count of TEXT fields that can be stored under various strict‑mode settings.

DatabaseDesignInnoDBMySQL
0 likes · 12 min read
Understanding MySQL Row Size Limits and the Maximum Number of TEXT Columns
Full-Stack Internet Architecture
Full-Stack Internet Architecture
Oct 6, 2019 · Databases

MySQL Index Failure When VARCHAR Condition Lacks Quotes

The article explains how omitting single quotes around a VARCHAR value in MySQL queries causes implicit type conversion, leading to full table scans and index loss, illustrated with MyBatis examples and detailed code snippets.

DatabaseMyBatisMySQL
0 likes · 5 min read
MySQL Index Failure When VARCHAR Condition Lacks Quotes
Aikesheng Open Source Community
Aikesheng Open Source Community
Jul 16, 2019 · Databases

Storing and Retrieving Large Image Files in MySQL: Comparing LONGBLOB, LONGTEXT, and VARCHAR

This article demonstrates how to store 5 MB images in MySQL using LONGBLOB, LONGTEXT, and VARCHAR columns, compares their disk usage, shows insertion scripts, and provides retrieval methods including a stored procedure for binary export, concluding that storing file paths is more efficient.

LONGTEXTMySQLSQL Procedure
0 likes · 7 min read
Storing and Retrieving Large Image Files in MySQL: Comparing LONGBLOB, LONGTEXT, and VARCHAR
Qunar Tech Salon
Qunar Tech Salon
May 1, 2015 · Databases

Performance Impact of Using TIMESTAMP vs VARCHAR for Date‑Time Data in Large Tables

Replacing a VARCHAR column that stores timestamp strings with a native TIMESTAMP type in a massive sorting table reduced query time from over 20 minutes to 39 seconds, demonstrating a 30‑plus‑fold speedup due to smaller storage, faster CPU comparisons, and reduced I/O.

OptimizationPerformanceVARCHAR
0 likes · 6 min read
Performance Impact of Using TIMESTAMP vs VARCHAR for Date‑Time Data in Large Tables