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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:45:55+00:00 2026-06-09T16:45:55+00:00

This takes between 2-4 seconds normally, which seems like far too long for the

  • 0

This takes between 2-4 seconds normally, which seems like far too long for the work it is doing.
Here is the AJAX:

$("#IngTable").html("<center><img src=../img/loading.gif /></center>");

    var search = document.getElementById("IngSearch").value;
    var apiLink = "/API/Ingredient/Search?search=" + search;
    $.ajaxSetup({ accepts: "application/json" });
    $.ajax({
        url: apiLink,
        type: "GET",
        success: function(data) {
            var ingredients = JSON.parse(data);
            var htmlIngred = "";
            for (var i = 0; i < ingredients.length; i++) {
                htmlIngred += "<tbody><td><span>" + ingredients[i].Name + "</span></td><td><a class='btn btn-success btn-mini' onclick='addIngred(" + ingredients[i].IngredientId + ");'>Add</a></td></tbody>";
            }
            document.getElementById("IngTable").innerHTML = htmlIngred;
        },
        error: function (a, b, c) { }
    });

And here is the Web API Controller:

    [HttpGet]
    public string IngredientSearch(string search)
    {
        var sw = Stopwatch.StartNew();
        var db = new Glubee.Model.GlubeeEntities();
        var results = db.Ingredients.Where(x => x.Name.Contains(search)).ToArray();
        sw.Stop();
        return JsonConvert.SerializeObject(results);
    }

There is only 16 things in the ingredients table, each being no more than 20 characters long.

Does anyone have any idea where the issue might be in this that makes it take so long?

Edit: Here is my Global.asax.cs page if it is helpful:

public class MvcApplication : System.Web.HttpApplication
{
    protected void Application_Start()
    {
        AreaRegistration.RegisterAllAreas();

        FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
        RouteConfig.RegisterRoutes(RouteTable.Routes);
        BundleConfig.RegisterBundles(BundleTable.Bundles);
    }

And here is my RouteConfig:

public class RouteConfig
{
    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

        routes.MapHttpRoute(
            name: "DefaultApi",
            routeTemplate: "api/{controller}/{id}",
            defaults: new { id = RouteParameter.Optional }
        );

        routes.MapRoute(
            name: "Default",
            url: "{controller}/{action}/{id}",
            defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
        );
    }
}
  • 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-09T16:45:57+00:00Added an answer on June 9, 2026 at 4:45 pm

    Have you identified exactly what’s slow yet ?

    For example; in your IngredientSearch method, if you change the code from

    [HttpGet]
    public string IngredientSearch(string search)
    {
        var sw = Stopwatch.StartNew();
        var db = new Glubee.Model.GlubeeEntities();
        var results = db.Ingredients.Where(x => x.Name.Contains(search)).ToArray();
        sw.Stop();
        return JsonConvert.SerializeObject(results);
    }
    

    to

    [HttpGet]
    public string IngredientSearch(string search)
    {
        return String.Empty;
    }
    

    Does it still take a long time ?

    If so; then we’ve got to look at a script library problem; if not – then it’s your DB layer that’s at fault.

    Bugs like this are often a pain to track down, so you must forget assumptions and test things bit by bit.
    The above change eliminates a lot of problems, for very little effort gives you a big clue.

    PS: Sorry, I know this isn’t an answer as such; but I wanted to post it as one so that I could highlight the code change clearly; please don’t down-vote!

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

Sidebar

Related Questions

For instance, this takes 4 lines which is too much space for such a
Let's say in PHP I have a string-variable : This takes between 5 and
I am taking inputs in Ruby like this: lines = STDIN.readlines.map{|x| x.strip.to_i}.sort This takes
I have code, which i want to run, this takes a few mins so
This code takes 3 seconds on Chrome and 6s on Firefox. If I write
This query takes about 52 seconds to complete. It appears 82% of the time
This query takes ~4 seconds to complete: SELECT DISTINCT resources_resource.id, resources_resource.heading, resources_resource.name, resources_resource.old_name, resources_resource.clean_name,
When I execute the following code it takes between 10-12 seconds to respond. Is
I got an array of 650 rows. Inserting this using PDO takes between 10-15
I recently noticed the CallByName keyword in VB6. Since this takes a object, procedure

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.