SELECT 
  gallery_id 
FROM 
  cscart_cp_image_gallery_links 
WHERE 
  object_type = 'P' 
  AND object_id = 313 
  AND link_type = 'A'

Query time 0.00027

JSON explain

{
  "query_block": {
    "select_id": 1,
    "table": {
      "message": "Impossible WHERE noticed after reading const tables"
    }
  }
}