Skip to content

Instantly share code, notes, and snippets.

1) The following query is really slow. What could be the reason? Propose some possible solutions. How to speed it up? Find all relations between tables base on the example code. If it requires, please rewrite the method.

def first_tag_history(tag, asin, marketplace_id)
  TagHistory.joins(product_tag: { product: :account }).where("
    product_tags.tag = :tag
    AND tag_histories.created_at >= CURDATE()
    AND products.asin = :asin
    AND accounts.marketplace_id = :marketplace
 ", {
api.RenderTemplate(w, "user/profile", params)
api.RenderTemplate(w, "signup", params)
api.RenderTemplate(w, "dashboard", "user/profile", params)
api.RenderTemplate(w, "auth", "signup", params)
==4418== ERROR: AddressSanitizer: heap-use-after-free on address 0x6006001f9090 at pc 0x7f4eeeb3a02b bp 0x7f4ed5af54b0 sp 0x7f4ed5af54a8
READ of size 8 at 0x6006001f9090 thread T268 (ice thread)
[1628829176] ICE send thread leaving...
#0 0x7f4eeeb3a02a (/opt/janus/lib/janus/plugins/libjanus_audiobridge.so.0.0.0+0x1502a)
#1 0x41cac3 (/opt/janus/bin/janus+0x41cac3)
#2 0x7f4f0407447e (/lib/x86_64-linux-gnu/libssl.so.1.0.0+0x3247e)
#3 0x7f4f040611d3 (/lib/x86_64-linux-gnu/libssl.so.1.0.0+0x1f1d3)
#4 0x420a7e (/opt/janus/bin/janus+0x420a7e)
#5 0x43cef0 (/opt/janus/bin/janus+0x43cef0)
#6 0x7f4f04c27995 (/usr/lib/x86_64-linux-gnu/libnice.so.10.2.0+0xa995)
package main
import (
"fmt"
"log"
"github.com/gorilla/mux"
"github.com/gorilla/websocket"
"time"
"net/http"
)