小编Can*_*liş的帖子

复合键laravel模式构建器

我需要两个复合主键,只有一个应该是AUTO INCREMENT我到目前为止尝试的:

// first try 
Schema::create("kitchen", function($table) {
                $table->increments('id');
                $table->integer('restaurant_id');
                $table->primary(array('id', 'restaurant_id'));
                $table->string('name');
            });
// second try
 Schema::create("kitchen", function($table) {
                $table->increments('id');
                $table->integer('restaurant_id');
                $table->primary('restaurant_id');
                $table->string('name');
            });
Run Code Online (Sandbox Code Playgroud)

没有用.错误信息:

[Exception]
SQLSTATE[42000]: Syntax error or access violation: 1068 Multiple primary ke
y defined (SQL: alter table
kitchen restaurant_idadd primary key kitchen_restaurant_id
_primary(
)) (Bindings: array (
))

没有Schema构建器的解决方案:首先,我需要添加两个复合主键,然后我需要创建一个,AUTO INCREMENT但我认为Schema构建器不能这样做.

注意:我可以用SQL做到这一点,我的意思是没有问题

有什么建议?

摘要:

我需要的是;

http://oi39.tinypic.com/es91ft.jpg

Schema建设者

php laravel

12
推荐指数
4
解决办法
1万
查看次数

MySQL中许多索引的缺点

情况

我有一个表调用follow,这是表结构:

- follower_id
- following_id
- when // timestamp
Run Code Online (Sandbox Code Playgroud)

这些是我执行的SQL查询:

SELECT * FROM follow WHERE follower_id = ? ORDER BY when LIMIT 0,20
SELECT * FROM follow WHERE following_id = ? ORDER BY when LIMIT 0,20
SELECT * FROM follow WHERE follower_id = ?
SELECT * FROM follow WHERE following_id = ?
Run Code Online (Sandbox Code Playgroud)

这些是我的索引:

follower_id, when
following_id, when
follower_id
following_id
Run Code Online (Sandbox Code Playgroud)

这种方法是真的吗?并且在DB中具有此数量(或多于此数量)的索引是否有任何缺点?

mysql database indexing

6
推荐指数
1
解决办法
6088
查看次数

dict pop不释放内存

看起来垃圾收集器不popdict()python 2.7中收集值'd (没有尝试python 3).这是一个例子:

a = dict()

# fill the memory (dict)
for i in xrange(0, 9999999):
    a[i] = i

# Memory usage is about 600 MB
# try to free the memory
for i in xrange(0, 9999999):
    a.pop(i)

# print the dict and see it is empty
print "%r" % a
# prints: {}
# Memory usage is about 600 MB

import copy
a = copy.copy(a)
# Memory usage decreased to about 200 MB

import …
Run Code Online (Sandbox Code Playgroud)

python memory dictionary memory-leaks memory-management

3
推荐指数
1
解决办法
656
查看次数

Laravel4内存消耗问题

案件

目前我正在使用Laravel 4开发应用程序.我安装了探查器以查看有关我的应用程序的统计信息.这是截图:

在此输入图像描述

问题

  • 您可以看到它在我的流浪者(Ubuntu 64位+ Nginx + PHP 5.3.10+ MySQL)中为每个请求(非常简单的页面)消耗12.25 MB内存.你觉得这太过分了吗?这意味着如果我有100个并发连接,则内存消耗将约为1 GB.我觉得这太多了,你觉得怎么样?
  • 它为每个请求加载237个文件.你觉得这太过分了吗?
  • 当我将此应用程序部署到我的服务器(使用带有Zend OPcache + MySQL的Apache + PHP 5.5.3的Centos 6.4)时,内存消耗会急剧下降.这是来自服务器的屏幕截图:

在此输入图像描述

您如何看待我的mac和服务器之间的这种差异?

php laravel-4

2
推荐指数
1
解决办法
2292
查看次数