首页 \ 问答 \ Mysql有效索引(Mysql effective indexes)

Mysql有效索引(Mysql effective indexes)

目前我正在创建索引,因为我需要它们用于特定的sql查询。 但他们开始相互重叠。

是否有任何规则可以有效地定义它们?

例如:

  • 如果我有column1和column2的两个索引,则column1,column2的复合索引是否会改进两列的选择?
  • column1和column2之间的索引与column2和column1之间的索引有什么区别?

Currently I am creating indexes as I need them for a particular sql query. But they are starting to overlap each other.

Is there any rule to define them effectively?

For example:

  • If I have two indexes for column1 and column2, does the composite index by column1, column2 improve select by both columns?
  • What is there any difference between an index by column1 and column2 over index by column2 and column1?

原文:https://stackoverflow.com/questions/13194219
更新时间:2023-08-31 07:08

最满意答案

我的队友,我刚刚在一个VPC中实现了ELB,在不同的可用区域中有2个私有子网。 您得到超时的原因是,对于添加到负载平衡器的每个子网,它将获得一个外部IP地址。 (尝试'dig elb-dns-name-here',你会看到几个IP地址)。 如果其中一个IP地址映射到一个私有子网,它将超时。 映射到公共子网中的IP地址将会起作用。 因为DNS可能会给你任何一个IP地址,有时它的工作,有时它超时。

经过一些亚马逊回来之后,我们发现ELB应该被放置在“公共”子网中,即有一条路由到Internet Gateway的子网。 我们希望将我们的网络服务器保留在我们的私有子网中,但允许ELB与他们交谈。 为了解决这个问题,我们必须确保我们在每个可用区域中都有一个相应的公共子网,我们有私有子网。 然后,我们将ELB添加到每个可用区域的公共子网。

起初,这似乎没有起作用,但是在尝试了一切之后,我们重新创建了ELB,并且一切正常工作。 我认为这是一个错误,或者ELB从这么多变化中处于一个奇怪的状态。

这里或多或少是我们所做的:

  1. WebServer-1在可用区域us-east-1b中的PrivateSubnet-1中运行,安全组称为Web服务器。
  2. WebServer-2在可用区域us-east-1c中的PrivateSubnet-2中运行,安全组称为Web服务器。
  3. 在区域us-east-1b中创建一个公共子网,我们称之为PublicSubnet-1。 我们确保将包含到Internet Gateway(ig-xxxxx)的路由的路由表与此新子网相关联。 (如果您使用向导创建公用/私有VPC,则此路由已存在。)
  4. 在区域us-east-1c中创建一个公共子网,我们称之为PublicSubnet-2。 我们确保将包含到Internet Gateway(ig-xxxxx)的路由的路由表与此新子网相关联。 (如果您使用向导创建公用/私有VPC,则此路由已存在。)
  5. 创建一个新的ELB,添加到PublicSubnet-1和PublicSubnet-2(而不是PrivateSubnet-X)。 此外,选择在ELB中运行的实例,在这种情况下是WebServer-1和WebServer-2。 确保分配一个允许传入端口80和443的安全组。让我们调用此组elb-group。
  6. 在Web服务器组中,允许来自elb组的端口80和443的流量。

我希望有帮助!


My teammate and I just have implemented ELB in a VPC with 2 private subnets in different availability zones. The reason you get timeouts is that for each subnet you add to the load balancer, it gets one external IP address. (try 'dig elb-dns-name-here' and you will see several IP addresses). If one of these IP address maps a private subnet, it will timeout. The IP that maps into your public subnet will work. Because DNS may give you any one of the IP addresses, sometimes it works, sometimes it times out.

After some back and forth with amazon, we discovered that the ELB should only be placed in 'public' subnets, that is subnets that have a route out to the Internet Gateway. We wanted to keep our web servers in our private subnets but allow the ELB to talk to them. To solve this, we had to ensure that we had a corresponding public subnet for each availability zone in which we had private subnets. We then added to the ELB, the public subnets for each availability zone.

At first, this didn't seem to work, but after trying everything, we recreated the ELB and everything worked as it should. I think this is a bug, or the ELB was just in an odd state from so many changes.

Here is more or less what we did:

  1. WebServer-1 is running in PrivateSubnet-1 in availability zone us-east-1b with security group called web-server.
  2. WebServer-2 is running in PrivateSubnet-2 in availability zone us-east-1c with security group called web-server.
  3. Created a public subnet in zone us-east-1b, we'll call it PublicSubnet-1. We ensured that we associated the routing table that includes the route to the Internet Gateway (ig-xxxxx) with this new subnet. (If you used the wizard to create a public/private VPC, this route already exists.)
  4. Created a public subnet in zone us-east-1c, we'll call it PublicSubnet-2. We ensured that we associated the routing table that includes the route to the Internet Gateway (ig-xxxxx) with this new subnet. (If you used the wizard to create a public/private VPC, this route already exists.)
  5. Created a new ELB, adding to it PublicSubnet-1 and PublicSubnet-2 (not the PrivateSubnet-X). Also, picked the instances to run in the ELB, in this case WebServer-1 and WebServer-2. Made sure to assign a security group that allows incoming port 80 and 443. Lets call this group elb-group.
  6. In the web-server group, allow traffic from port 80 and 443 from the elb-group.

I hope that helps!

相关问答

更多
  • 你引用的另一个问题是现货。 双人/三人检查以下内容 您只需要将公有子网连接到ELB,确保这些子网的可用区域与您的实例所在的私有子网的可用区域保持一致。 确保实例的安全组允许从负载均衡器的安全组访问 确保您的运行状况检查在实例本地工作。 例如,如果您在ELB中的运行状况检查为HTTP:8080/health_check ,则可以在实例上curl xxxx:8080/health_check (其中xxxx是实例的私有IP)并获得200响应代码。 公共子网路由表应将0.0.0.0/0路由到连接到VPC的Inte ...
  • 看来,从没有弹性IP的实例中获取外部的唯一方法是: 添加NAT(从ami-vpc-nat-beta启动一个额外的m1.small实例)并将EIP分配给它 创建一个额外的子网将是“私有” 将非EIP实例移动到该专用子网 修改路由表:私有子网的0.0.0.0/0应该去NAT 所以,只是添加NAT是不够的。 实例应停止,并从另一个子网移动到另一个IP。 It appears that the only way to get outside from instances that don't have Elasti ...
  • 我的队友,我刚刚在一个VPC中实现了ELB,在不同的可用区域中有2个私有子网。 您得到超时的原因是,对于添加到负载平衡器的每个子网,它将获得一个外部IP地址。 (尝试'dig elb-dns-name-here',你会看到几个IP地址)。 如果其中一个IP地址映射到一个私有子网,它将超时。 映射到公共子网中的IP地址将会起作用。 因为DNS可能会给你任何一个IP地址,有时它的工作,有时它超时。 经过一些亚马逊回来之后,我们发现ELB应该被放置在“公共”子网中,即有一条路由到Internet Gateway的 ...
  • 已解决:此错误是使用旧版AWS API的aws-sdk gem的ELB部分的结果。 2012年8月6日发布了新的gem版本(1.6.1),导致ELB使用2012-06-01版本的API,现在可以使用问题中的代码将实例添加到ELB。 Resolved: This error was the result of the ELB portion of the aws-sdk gem using an old version of the AWS API. A new gem version (1.6.1) was ...
  • 我只是花了一天的眼泪试图让枪炮(基于python)在ELB后面工作。 我看起来好像在nginx后面工作得很好(手指交叉)。 确保elb健康检查不直接传送给独角兽。 它应该通过nginx。 这是我的理解,独角兽的风格是获得一个请求,处理它,然后继续前进。 ELB希望保持连接畅通,以提高效率。 Nginx可以处理许多连接,并且没有任何问题。 I just spent a day in tears trying to get gunicorn (python based) to work behind the E ...
  • 这似乎是您的计算机或DNS服务器中的DNS缓存问题。 要清除计算机中的缓存,请使用ipconfig /flushdns刷新DNS 如果问题仍然存在,请尝试使用traceroute www.example.com(或在Windows中跟踪www.example.com)查看它是否到达ELB。 如果源IP与当前DNS配置不同, 这可能是由于配置错误(仔细检查) 如果未传播最新的DNS修改(如果其指向先前的配置),则等待一段时间,直到DNS服务器根据TTL值清除缓存。 This seems like a DNS ...
  • 如果选中,将使用与其关联的公共IP地址创建ELB(如果在设置期间选择单个实例而不是负载平衡,则将使用EC2实例)。 可见性仅适用于ACL,并且实际上不会为其提供可公开访问的IP。 在常见的VPC设置中,您将拥有公共和私有子网,它们之间具有NAT。 公共子网中的东西通常可以访问Internet和私有子网。 私有子网通常只能访问本地子网。 在负载平衡的EB环境中,通常将ELB放在公有子网中,将EC2实例放在私有子网中。 VPC安全组适用于您的资源(VPC中的任何内容)。 它们只是以术语VPC为前缀,以便区分VP ...
  • 如果要在ELB上提供HTTPS,则还需要提供SSL证书。 所以你的ec2_elb_lb任务应该如下所示: - name: Create VPC network ec2_elb_lb: aws_access_key: "{{ aws_access_key }}" aws_secret_key: "{{ aws_secret_key }}" name: "ElasticLoadBalancer" region: us-east-1 ...
  • 每个AWS账户都有自己的AZ集。 获取可以帮助使用AWS cli工具的可用AZ列表: aws ec2 describe-availability-zones 请在此处查看详细信息: http : //docs.aws.amazon.com/cli/latest/reference/ec2/describe-availability-zones.html Each AWS account has own set of the AZ. Get list of the available AZ you can ...
  • 不,这不正确。 除了健康检查之外,ELB不关心实例的响应代码是什么。 ELB也不向两个实例发送单个请求。 No, that is not correct. Other than the health check the ELB does not care what the response code from the instances is. The ELB also does not send a single request to both instances.

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)