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 8298883
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T15:56:43+00:00 2026-06-08T15:56:43+00:00

SELECT * FROM items WHERE caption LIKE ‘name%’ AND type = ‘private’ OR owner

  • 0
SELECT * FROM items WHERE caption LIKE 'name%' AND type = 'private' OR owner LIKE 'name%' type = 'private' ORDER BY uses DESC LIMIT 40;

Possible keys: items_caption,items_owner,items_type
Key: items_uses
(Got these by using the explain command)

It takes about 1.8 seconds to do that query and there are over million records in the table. I don’t know how to make a index for this query and I’ve no control over the source so I can’t modify the query.

  • 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-06-08T15:56:44+00:00Added an answer on June 8, 2026 at 3:56 pm

    Since you’ve got at select *, you can’t really do a covering index, but you could do a pair of composite indexes on (caption,type) and (owner, type).

    ALTER TABLE items ADD INDEX (caption, type);
    ALTER TABLE items ADD INDEX (owner, type);
    

    This should cut down on internal point lookups.

    I don’t think you need fulltext search since the value you’re comparing with your LIKE’s do not start with a wildcard (%). Likes that compare with strings not starting with % can use traditional fast b-tree indexes. If you have a % at the start of the LIKE as in ‘%name’ this wouldn’t be the case.

    Also, don’t forget the conditions your searching are:

    caption LIKE ‘name%’ AND type = ‘private’

    OR

    owner LIKE ‘name%’ AND type = ‘private’

    So “ADD FULLTEXT(caption,owner)” won’t help much if the caption clause fails and it tries to lookup by owner and type.

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

Sidebar

Related Questions

Assuming a generic query like: SELECT * FROM items ORDER BY type ASC, created
Is the following query SELECT * FROM items WHERE field1 NOT LIKE '%a%' AND
When we use jgGrid, like this: get_items.php => $SQL = SELECT * FROM items
int a ; SqlCommand cmd = new SqlCommand ( Select * From items order
$data = $mysqli->prepare(SELECT amount FROM items WHERE id=:id); echo 'forward1'; if(!$data->execute(array(':id' => $id))) die(error
My webpage allows users to select items from a dropdown list and has a
i wrote in file showList.php the following form, which select items from the database
I want to make a view where I can select multiple items from listview
What is a scalable way to select latest 10 items from each category. I
I have a set of items, from which I want to select DISSIMILAR tuples

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.