iRealtee OS Glossary

Database Indexing

A database index works like a book's index—instead of reading every page to find a topic, you look up the keyword in the index and jump directly to the relevant...

Database Indexing

Database Indexing is a data structure technique that improves the speed of data retrieval operations by creating a sorted reference map to records in a database table. In real estate platforms, proper indexing enables instant property searches, fast client lookups, and responsive reporting—even when databases contain millions of records.

Definition

A database index works like a book's index—instead of reading every page to find a topic, you look up the keyword in the index and jump directly to the relevant pages. Similarly, a database index stores sorted values from specific columns along with pointers to the actual data rows, allowing the database engine to locate records without scanning the entire table.

Without indexes, every query performs a "full table scan," examining each row sequentially. With proper indexing, the database uses efficient search algorithms (like binary search) to find data in milliseconds rather than seconds.

How Database Indexes Work

Component Function
Index Key The value from the indexed column used for searching
Data Pointer Reference to the actual record location in the table
Data Structure Usually a B-tree (balanced tree) that keeps data sorted
Index Entries Sorted list of keys with their corresponding pointers

Query Without Index:

  1. Database receives query: "Find all properties in Makati"
  2. Engine scans every row in the properties table
  3. Checks each row's location field
  4. Returns matching records
  5. Time complexity: O(n) — slows as data grows

Query With Index on Location:

  1. Database receives query: "Find all properties in Makati"
  2. Engine consults the location index (B-tree)
  3. Binary search finds "Makati" entries instantly
  4. Follows pointers to retrieve actual records
  5. Time complexity: O(log n) — remains fast even with millions of records

Index Types

Single-Field Index

Index on one column. Most common type for frequently queried fields.

Example: Index on property_price
Use case: "Find properties under PHP 5,000,000"

Compound Index

Index on multiple columns. Order matters—follows the ESR (Equality, Sort, Range) guideline.

Example: Index on (city, property_type, price)
Use case: "Find condos in Makati under PHP 10M, sorted by price"

Unique Index

Ensures no duplicate values in the indexed column. Automatically created for primary keys.

Example: Unique index on client_email
Use case: Prevent duplicate client registrations

Full-Text Index

Optimized for searching text content using natural language queries.

Example: Full-text index on property_description
Use case: "Find properties mentioning 'pool' and 'parking'"

Partial Index

Indexes only rows meeting specific criteria, reducing storage overhead.

Example: Index on status WHERE status = 'active'
Use case: Only index active property listings

Geospatial Index

Optimized for location-based queries using coordinates.

Example: Index on (latitude, longitude)
Use case: "Find properties within 5km of BGC"

Benefits of Database Indexing

Performance Improvements:

  • Queries execute in milliseconds instead of seconds
  • Sorting operations use pre-sorted index data
  • JOIN operations between tables become faster
  • Aggregate functions (COUNT, SUM) on indexed columns improve

User Experience:

Trade-offs and Considerations

Advantage Trade-off
Faster reads Slower writes (index must be updated)
Efficient sorting Additional storage space required
Quick lookups Index maintenance overhead
Better query plans Over-indexing degrades performance

When NOT to Index:

  • Columns rarely used in WHERE clauses
  • Tables with frequent INSERT/UPDATE operations
  • Low-cardinality columns (e.g., boolean fields with only true/false)
  • Small tables where full scans are already fast

Indexing Strategy for Real Estate Platforms

For Philippine real estate databases, prioritize indexes on:

Property Listings Table:

  • location — City/municipality searches
  • property_type — Filter by condo, house, lot
  • price — Range queries and sorting
  • developer_id — Filter by developer
  • status — Active/sold/reserved filtering
  • created_at — Sort by newest listings

Clients Table:

  • email — Unique constraint and login lookups
  • phone_number — Client search by contact
  • assigned_agent_id — Agent's client list queries
  • created_at — Recent leads reporting

Transactions Table:

  • property_id — Transaction history per property
  • client_id — Client purchase history
  • agent_id — Agent performance reports
  • transaction_date — Date range reporting
  • status — Pipeline stage filtering

Compound Index Example:

Index on (agent_id, transaction_date, status)
Supports: "Show Agent X's closed deals this month"

Index Monitoring and Optimization

Signs your database needs better indexing:

  • Queries taking longer than expected
  • High CPU usage during peak hours
  • Slow report generation
  • User complaints about search responsiveness

Optimization Steps:

  1. Identify slow queries using database query logs
  2. Analyze query execution plans (EXPLAIN in SQL)
  3. Add indexes for frequently filtered/sorted columns
  4. Remove unused or redundant indexes
  5. Consider partial indexes for large tables
  6. Monitor index usage statistics regularly

References

Looking for another term? Browse the full glossary.

Back to Glossary