jjzjj

postgresql

全部标签

ruby-on-rails - Rails Postgresql 多个模式和相同的表名

我在两个不同的模式中有两个表,例如案例和事件。在每个模式中我都有基本表events.basiccases.basic这个表有关系:events.basic有一个cases.basic(cases.basic有多个events.basic)我的尝试失败了:文件cases_basic.rbclassCasesBasic'EventsBasic',:foreign_key=>'case_id'end文件events_basic.rbclassEventsBasic'CasesBasic',:foreign_key=>'case_id'end环境:Ruby1.9.3、Rails3.1.3、ge

ruby - Rails+ActiveAdmin - 使用 ransacker 过滤会抛出错误 PG::SyntaxError: ERROR: syntax error at or near ","

我在RubyonRails4.1.4上有一个项目,使用来自git://github.com/activeadmin/activeadmin的activeadmin1.0.0.pre,pg0.17.1,PostgreSQL9.3在项目中我有这些模型:类用户has_one:账户类账户属于:用户有很多:project_accountshas_many:项目,:through=>:project_accounts类项目#该项目有一个bool属性'archive'has_many:project_accounts类ProjectAccount属于:帐户属于:项目我有一个任务是在索引页面上实现一个

ruby-on-rails - ActiveRecord::QueryCache#call 占用了超过 70% 的执行时间

NewRelic向我展示了应用服务器中超过80%的执行时间发生在“MiddlewareActiveRecord::QueryCache#call”中这里是相关测试代码的要点(尽管我在其他API端点上看到了类似的结果)。Gist我正在AWSElasticBeanstalk上的t2.medium实例和t2.smallPostgresRDSDB上运行应用程序服务器,max_connections设置为100。我正在通过loader.io对此进行测试,对100个用户进行测试使用维护客户端负载设置(这意味着每分钟大约6000个请求)。有谁知道为什么QueryCache花费这么多时间?

ruby - 有没有更简洁的方法来检查 PGResult 是否为空?

我正在使用pggem从Ruby与PostgreSQL对话。有没有检查是否没有结果比使用res.ntuples==0更好的方法?conn=PGconn.connectconfigcmd="select*fromlabelsinnerjoinlabels_mailusing(label_id)"+"wherelabels_mail.mail_id=$1andlabels.name=$2"res=conn.exec(cmd,[mail_id,mailbox])ifres.ntuples==0# 最佳答案 元组,打字错误?使用zero?比=

ruby - 升级到 Ruby 2.2.0 后出现符号查找错误

我得到这个错误,因为升级到2.2.0,只有当http请求发送到puma时才会发生:puma2.10.2(tcp://0.0.0.0:22555):symbollookuperror:/usr/lib/ruby/gems/2.2.0/extensions/x86_64-linux/2.2.0/do_postgres-0.10.14/do_postgres/do_postgres.so:undefinedsymbol:rb_thread_select这是什么原因,如何解决?降级到2.1.5无论如何都会解决这个问题。 最佳答案 版本0.1

ruby-on-rails - 使用 PostgreSQL 适配器限制 ActiveRecord 迁移 5.0 中的文本列

我的迁移看起来像这样classCreateQuestionings现在,当我运行$rakedb:migrate:reset时,在我的db/schema.rb中看不到限制:create_table"questionings",force::cascadedo|t|t.text"body",null:falseend我做错了吗还是这是一个错误?顺便说一下,我使用的是rails5.0.0.beta3和ruby​​2.3.0p0。 最佳答案 t.text在PostgreSQL和textdoesn'tallowforsizelimits中生成

ruby-on-rails - rails : Faster way to perform updates on many records

在我们的Rails3.2.13应用程序(Ruby2.0.0+Heroku上的Postgres)中,我们经常从API中检索大量订单数据,然后我们需要在我们的数据库中更新或创建每个订单,因为以及协会。单个订单创建/更新自身加上大约。10-15个关联对象,我们一次最多导入500个订单。下面的代码可以工作,但问题是它在速度方面一点也不高效。创建/更新500条记录大约需要。1分钟并生成6500多个数据库查询!defadd_details(shop,shopify_orders)shopify_orders.eachdo|shopify_order|order=Order.where(:order

ruby - 如何在 postgresql 中创建多列推荐引擎?

我在postgresql中有一个表,其中包含一些汽车+1000000条记录:+----+--------+------+---------+-----------+-------------+------------+------------+|id|price|year|mileage|fuel_type|body_type|brand|model|+----+--------+------+---------+-----------+-------------+------------+------------+|1|4894|2011|121842|"Benzin"|"Sedan

关于如何为 PostgreSQL 编写存储过程的 Ruby 教程?

听说PostgreSQL的可以用Ruby写存储过程但我一直没能找到更多关于它的信息,教人们如何实际去做。有人可以为此推荐好的资源。谢谢 最佳答案 显然,您需要安装PL/Ruby。之后,你可以写:CREATEFUNCTIONruby_max(int4,int4)RETURNSint4AS'ifargs[0].to_i>args[1].to_ireturnargs[0]elsereturnargs[1]end'LANGUAGE'plruby';查看其GitHubrepository安装说明。

ruby-on-rails - routes.rb - 不支持 Controller 名称

我遇到了一个很奇怪的问题。这是与routes.rb相关的部分:resources:playersmatch'/players/:userid',:to=>'Players#show'当您访问localhost:3000/players/1234时出现此错误:'Players'isnotasupportedcontrollername.Thiscanleadtopotentialroutingproblems.Controller中的相关代码:defshowbeginifPlayer.find_by(:uid=>:userid)then@playerattributes=Player.f