chrisbjr / api-guard

A simple way of authenticating your RESTful APIs with API keys using Laravel
MIT License
692 stars 147 forks source link

Slow Query #165

Open PaddyLock opened 5 years ago

PaddyLock commented 5 years ago

I am using api-guard in the normal way. When I look at the query times in the debug toolbar, the api-guard query is always tagged as slow:

select * fromapi_keyswherekey= '0b0c7be24c74c79c7efe7568b770749f1599cf60' andapi_keys.deleted_atis null limit 1

Time = 184.12ms

Why is the query so slow? What can I do to speed it up?

If I run the query direct on my database then it runs very quickly.

ratatatKE commented 5 years ago

Hi @PaddyLock, please list technical details of your installation:

Please be very very granular in your breakdown so that someone can get context of the scenario and see whether we can reproduce your issue.

PaddyLock commented 5 years ago

Hi @ratatatKE here are the details

"require": {
        "php": "^7.1.3",
        "barryvdh/laravel-debugbar": "^3.2",
        "chrisbjr/api-guard": "4.*",
        "darkaonline/l5-swagger": "5.7.*",
        "fideloper/proxy": "^4.0",
        "flow/jsonpath": "^0.4.0",
        "folklore/graphql": "^1.1",
        "laravel/framework": "5.7.*",
        "laravel/telescope": "^0.1.5",
        "laravel/tinker": "^1.0",
        "league/flysystem-cached-adapter": "^1.0"
    },

MySQL 5.5.53 hosted on AWS RDS db.m4.xlarge encoding: utf8mb4 engine: innoDB only two rows in api_keys table

Server is a Docker instance: nginx, php 7.2.

I am running the docker instance locally and connecting to the RDS database externally. All other DB connections run a lot faster. It's just the api key check that shows in the profiler as being slow.

PaddyLock commented 5 years ago

screen shot 2018-11-30 at 14 35 58

@ratatatKE