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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:36:21+00:00 2026-06-11T16:36:21+00:00

I have a very specific query I am currently doing with MySQL My Table

  • 0

I have a very specific query I am currently doing with MySQL

My Table structure is :

id : INT, primary KeY, AUTO_INCREMENT
occupationID : INT
alias : VARCHAR(255)

Then, I do a

SELECT occupationID, (MATCH(alias) AGAINST ('Web Developer' IN NATURAL LANGUAGE MODE) / count(*)) as score FROM aliases group by occupationID order by score DESC LIMIT 0,2;

This query performs a search on every ROW, doing a full scan, and divide matches by their number of occurrences. This way, I got an average score on all rows, giving me the accuracy I need.

This is very slow (20 sec) , with a 50k records table . ( I am not surprised, MySQL fulltext is very slow…).

With Sphinx, I was thinking to build an index with this query:

select id,occupationID,alias, (SELECT count(*) from aliases AS A WHERE B.occupationID=A.occupationID) as nb   from aliases AS B 

And then do a

$sphinx->setSelect("@id, sum(@weight)/nb as score");
$sphinx->setGroupBy("occupationID", GROUP_BY_ATTR, "score DESC");

and

$sphinx->query("Web Developer");

Am I doing this right?

  • 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-11T16:36:22+00:00Added an answer on June 11, 2026 at 4:36 pm

    Mostly. The only odity I spot, is in the original mysql, you group by occupationID. But in building the index you join with id – meaning the count will be the number with the same id, not the sample occupationID.

    I’m also not certain that sum(@weight) works in sphinx – in theory it should, but there are a few odd restrictions, so cant be sure without testing.

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

Sidebar

Related Questions

I have the following table structure: EVENT_ID(INT) EVENT_NAME(VARCHAR) EVENT_DATE(DATETIME) EVENT_OWNER(INT) I need to add
I have a very specific query that is acting up and I could use
I have a very specific case that I need to debug. I need to
I have a very specific SSL issue on my Android. If I try to
I have a very specific set of needs and am looking for a library
The problem that I have is somehow very specific. I have to implement a
I have a particular application that needs to calculate something very specific, and while
I have a custom closed-hashset/open-addressing (i.e. no linked lists) class. It's very specific to
I have a very odd issue. When I execute a specific database stored procedure
I am very much a beginner to rails and I have a specific need

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.