Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7128149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T11:06:30+00:00 2026-05-28T11:06:30+00:00

We are implementing a system that analyses books. The system is written in PHP,

  • 0

We are implementing a system that analyses books. The system is written in PHP, and for each book loops through the words and analyses each of them, setting certain flags (that translate to database fields) from various regular expressions and other tests.

This results in a matches table, similar to the example below:

+------------------------+--------------+------+-----+---------+----------------+
| Field                  | Type         | Null | Key | Default | Extra          |
+------------------------+--------------+------+-----+---------+----------------+
| id                     | bigint(20)   | NO   | PRI | NULL    | auto_increment |
| regex                  | varchar(250) | YES  |     | NULL    |                |
| description            | varchar(250) | NO   |     | NULL    |                |
| phonic_description     | varchar(255) | NO   |     | NULL    |                |
| is_high_frequency      | tinyint(1)   | NO   |     | NULL    |                |
| is_readable            | tinyint(1)   | NO   |     | NULL    |                |
| book_id                | bigint(20)   | YES  |     | NULL    |                |
| matched_regex          | varchar(255) | YES  |     | NULL    |                |
| [...]                  |              |      |     |         |                |
+------------------------+--------------+------+-----+---------+----------------+

Most of the omitted fields are tinyint, either 0 or 1. There are currently 25 fields in the matches table.

There are ~2,000,000 rows in the matches table, the output of analyzing ~500 books.

Currently, there is a “reports” area of the site which queries the matches table like this:

SELECT COUNT(*)
FROM matches
WHERE is_readable = 1
AND other_flag = 0
AND another_flag = 1

However, at present it takes over a minute to fetch the main index report as each query takes about 0.7 seconds. I am caching this at a query level, but it still takes too long for the initial page load.

As I am not very experienced in how to manage datasets such as this, can anyone advise me of a better way to store or query this data? Are there any optimisations I can use with MySQL to improve the performance of these COUNTs, or am I better off using another database or data structure?

We are currently using MySQL with MyISAM tables and a VPS for this, so switching to a new database system altogether isn’t out of the question.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T11:06:31+00:00Added an answer on May 28, 2026 at 11:06 am

    Add multi index to this table as you are selecting by more than one field. Below index should help a lot. Those type of indexes are very good for boolean / int columns. For indexes with varchar values read more here: http://dev.mysql.com/doc/refman/5.0/en/create-index.html

    ALTER TABLE `matches` ADD INDEX ( `is_readable`, `other_flag`, `another_flag` ) 
    

    One more thing is to check your queries by using EXPLAIN {YOUR WHOLE SQL STATEMENT} to check which index is used by DB. So in this example you should run query:

    EXPLAIN ALTER TABLE `matches` ADD INDEX ( `is_readable`, `other_flag`, `another_flag` ) 
    

    More info on EXPLAIN: http://dev.mysql.com/doc/refman/5.0/en/explain.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am implementing two processes on a LynxOS SE (POSIX conformant) system that will
I'm thinking about a good solution for implementing a sign up/login system that works
I am implementing a breakpoint system for use in my Python development that will
I can't find any documentation on implementing a class that inherits System.Windows.Media.Brush - what
I'm implementing a Announcement system that is loosely based on this article: https://web.archive.org/web/20211020111733/https://www.4guysfromrolla.com/articles/110409-1.aspx One
I have a system that filters template files through erb. Using convention over configuration,
I've been working on implementing a pretty complex system in JavaScript that needs to
We are implementing a fly out messaging system that will normally fly out while
I am implementing a system for touchscreens in java that needs to be able
I'm implementing a system that runs game servers. I have a process (the game

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.