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

  • Home
  • SEARCH
  • 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 5955713
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:09:11+00:00 2026-05-22T18:09:11+00:00

I have a database of thousands (about 10,000) keywords. When a user posts a

  • 0

I have a database of thousands (about 10,000) keywords. When a user posts a blog on my site, I would like to automatically search for the keywords in the text, and tag the post with any direct matches.

So far, all I can think of is to pull the ENTIRE list of keywords, loop through it, and check for the presence of each tag in the post…which seems very inefficient (that’s 10,000 loops).

Is there a more common way to do this? Should I maybe use a MySQL query to limit it down?

I imagine this is not a totally rare task.

  • 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-22T18:09:11+00:00Added an answer on May 22, 2026 at 6:09 pm

    No, just don’t do that.

    Instead of looping through 10000 elements, it is better to extract the words from the sentence or text, then add it to the SQL query and that way you will have all the needed records. This is surely more efficient than the solution you proposed.

    You can do this in the following way using PHP:

    $possible_keywords = preg_split('/\b/', $your_text, PREG_SPLIT_NO_EMPTY);
    

    The above will split the text on the words’ boundaries and will return no empty elements in the array.

    Then you just can create the SQL query in a fashion similar to the following:

    SELECT * FROM `keywords` WHERE `keywords`.`keyword` IN (...)
    

    (just put the comma-separated list of extracted words in the bracket)

    You should probably filter the $possible_keywords array before making the query (to include only the keywords with appropriate length and to exclude duplicates) plus make keyword column indexed.

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

Sidebar

Related Questions

I have a database table with hundreds of thousands of forum posts, and I
I have a database in single user mode and I am trying to drop
I have a snippet to create a 'Like' button for our news site: <iframe
I have lists of about 20,000 items that I want to insert into a
I have a MySQL database table with a couple thousand rows. The table is
I have database with many tables. In the first table, I have a field
I have a database that contains a date and we are using the MaskedEditExtender
I have a database table and one of the fields (not the primary key)
I have designed database tables (normalised, on an MS SQL server) and created a
I have a database with names in it such as John Doe etc. Unfortunately

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.