小编mOn*_*Ona的帖子

使用mysql处理非常大的数据

对不起,很长的帖子!

我有一个包含~30个表(InnoDB引擎)的数据库.这些表中只有两个,即"事务"和"移位"非常大(第一个有150万行,移位有23k行).现在一切正常,我没有当前数据库大小的问题.

但是,我们将有一个类似的数据库(相同的数据类型,设计,...),但更大,例如,"交易"表将有大约10亿条记录(每天约2,300万笔交易),我们正在考虑如何我们应该在MySQL中处理这么大量的数据?(这是读写密集型).我阅读了很多相关帖子,看看Mysql(更具体地说是InnoDB引擎)是否可以与数十亿条记录表现良好,但我仍然有一些问题.我读过的一些相关帖子如下:

到目前为止我已经理解为提高非常大的表的性能:

  1. (对于我的情况下的innoDB表)增加innodb_buffer_pool_size(例如,高达80%的RAM).此外,我在percona博客中找到了一些其他MySQL性能调整设置
  2. 在表上有适当的索引(在查询上使用EXPLAN)
  3. 分区表
  4. MySQL Sharding或群集

这是我的问题/困惑:

  • 关于分区,我怀疑是否应该使用它.一方面,许多人建议在桌子非常大时提高性能.另一方面,我读过许多帖子,说它不会提高查询性能,也不会使查询运行得更快(例如,这里这里).另外,我在MySQL参考手册中读到InnoDB外键和MySQL分区不兼容(我们有外键).

  • 关于指标,现在他们表现良好,但据我了解,对于非常大的表的索引是更严格(如凯文·比德尔在他的回答中提到在这里).此外,索引加速读取,同时减慢写入(插入/更新).那么,对于我们将拥有这个大型数据库的新类似项目,我们应该首先插入/加载所有数据然后创建索引吗?(加快插入速度)

  • 如果我们不能对我们的大表("事务"表)使用分区,那么提高性能的另一种选择是什么?(除了MySQl变量设置之外innodb_buffer_pool_size).我们应该使用Mysql集群吗?(我们也有很多连接)

编辑

这是show create table我们最大的名为"transaction"的表的声明:

  CREATE TABLE `transaction` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 `terminal_transaction_id` int(11) NOT NULL,
 `fuel_terminal_id` int(11) NOT NULL,
 `fuel_terminal_serial` int(11) NOT NULL,
 `xboard_id` int(11) NOT NULL,
 `gas_station_id` int(11) NOT NULL,
 `operator_id` text NOT NULL,
 `shift_id` int(11) NOT …
Run Code Online (Sandbox Code Playgroud)

mysql database indexing performance partitioning

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

jQuery Validation插件errorPlacement for checkbox

我使用jQuery Validation插件来验证我的表单.我的问题是复选框的错误消息的位置.请看这个图像:

在此输入图像描述

这是与复选框+ jQuery验证相关的html部分:

<fieldset id = "q8"> <legend class="Q8"></legend>
<label> What are your favourite genres of movies?<span>*</span></label>
<div class="fieldset content"> 

<style type="text/css">
 .checkbox-grid li {
 display: block;
 float: left;
 width: 25%;
}     
</style>

<ul class="checkbox-grid">
<li><input type="checkbox" name="q8[]" value="Action"><label for="checkgenre[]">Action</label></li>
<li><input type="checkbox" name="q8[]" value="Adventure"><label for="checkgenre[]">Adventure</label></li>
<li><input type="checkbox" name="q8[]" value="Comedy"><label for="checkgenre[]">Comedy</label></li>
<li><input type="checkbox" name="q8[]" value="Animation"><label for="checkgenre[]">Animation</label></li>
<li><input type="checkbox" name="q8[]" value="Drama"><label for="checkgenre[]">Drama</label></li> 
<li><input type="checkbox" name="q8[]" value="Romance"><label for="checkgenre[]">Romance</label></li>
  //Continued the same for OTHER CHECKBOXES 

</div>
</fieldset>

  //html for other questions...

 <input class="mainForm" …
Run Code Online (Sandbox Code Playgroud)

checkbox jquery jquery-validate errorplacement

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

如何修复HTTP错误提取URL.在抓取时java中的状态= 500?

我试图从评论页面抓取用户对imdb影院电影的评分:(我数据库中的电影数量约为600,000).我使用jsoup来解析页面如下:(对不起,我没有在这里编写整个代码,因为它太长了)

try {
  //connecting to mysql db
  ResultSet res = st
        .executeQuery("SELECT id, title, production_year " +
                "FROM title " +
                "WHERE kind_id =1 " +
                "LIMIT 0 , 100000");
  while (res.next()){
       .......
       .......
     String baseUrl = "http://www.imdb.com/search/title?release_date=" +
            ""+year+","+year+"&title="+movieName+"" +
            "&title_type=feature,short,documentary,unknown";
    Document doc = Jsoup.connect(baseUrl)
            .userAgent("Mozilla")
            .timeout(0).get();
      .....
      ..... 
//insert ratings into database
      ...
Run Code Online (Sandbox Code Playgroud)

我测试了它的前100个,然后是前500个,也是我的数据库中的前2000个电影,它运行良好.但问题是,当我测试了100,000部电影时,我收到了这个错误:

org.jsoup.HttpStatusException: HTTP error fetching URL. Status=500,   URL=http://www.imdb.com/search/title?release_date=1899,1899&title='Columbia'%20Close%20to%20the%20Wind&title_type=feature,short,documentary,unknown
at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:449)
at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:424)
at org.jsoup.helper.HttpConnection.execute(HttpConnection.java:178)
at org.jsoup.helper.HttpConnection.get(HttpConnection.java:167)
at imdb.main(imdb.java:47)
Run Code Online (Sandbox Code Playgroud)

我搜索了很多这个错误,我发现它是一个服务器端错误,错误号为5xx.

然后我决定设置一个条件,当连接失败时,它再尝试2次然后如果仍然无法连接,则不会停止并转到下一个URL.因为我是java的新手,所以我试图在stackoverflow中搜索类似的问题并阅读这些答案:

我从网站提取数据时的例外情况

当无法连接到网站时,Jsoup错误处理

处理连接错误和JSoup

但是,当我按照他们的建议尝试使用"Connection.Response"时,它会告诉我"Connection.Response无法解析为某种类型".

我很感激,如果有人可以帮助我,因为我只是一个新手,我知道它可能很简单,但我不知道如何解决它. …

java web-crawler http-error jsoup

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

无法登录phpmyadmin错误#1862 - 您的密码已过期

我按照本教程安装了mysql,php和phpmyadmin .Evrything运行良好,即我可以通过命令行启动并连接到mysql而没有任何错误,但问题是当我尝试登录到phpmyadmin时,我收到此错误:

#1862 - 您的密码已过期.要登录,您必须使用支持过期密码的客户端进行更改.

可能值得一提的是,我当前的mysql密码不是我安装mysql时收到的临时密码,但我稍后更改了(安装phpmyadmin之前),现在尝试使用这个新的(当前)密码登录phpmyadmin告诉我以上错误.

请有人帮我理解是什么问题?

谢谢

mysql login phpmyadmin

8
推荐指数
1
解决办法
9759
查看次数

如何将 Java ArrayList 插入 MySQL 表?

有人可以告诉我如何将 Arraylist 的值作为单个字符串插入 MySQL 表中吗?

例如,将“犯罪、戏剧、动作”插入表“featuredfilms_INFO”的“流派”列中。

这是我的代码的一部分:

int i = 0;
List<String> genre = new ArrayList<String>();
.
.
.
Elements elms1 = doc.select("div.infobar"); 
Elements links1 = elms1.select("a[href]");
for (Element link1 : links1){
    if (link1.attr("href").contains("/genre/")) {
        genre.add(links1.get(i).text());
        i++;
    }
}
System.out.println("movie genres:" + genre); 
.
.
try {
     String query = "INSERT into featuredfilms_INFO (movieId, genres)" + "VALUES (?, ?)";
     PreparedStatement preparedStmt = conn.prepareStatement(query);
     preparedStmt.setString (1, ID);
     preparedStmt.setString (2, genre);
   .
   .
   .
}
Run Code Online (Sandbox Code Playgroud)

我的问题是我不能setString用于流派,因为它不是字符串类型。我有点困惑,因为一开始我将流派定义为字符串,但经过一番搜索后,我发现在 Java 中,对于动态数组,我必须使用 …

java mysql jdbc arraylist

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

在子窗口中访问父本地变量

我想在子窗口中使用父级的局部变量.我用,parent.window.opener但它返回undefined.

这是我的代码:

<script type="text/javascript">
 var selectedVal;

 $(document).ready(function () {
  //....
  //...
   if ($(this).val() == "byActor"){
           $("#tags").focus();
           $("#tags").autocomplete({
             source: "actorsauto.php",
             minLength: 2,
             focus: function( event, ui ){
                   event.preventDefault(); 
                   return false;
             },
             select: function (event, ui){ 
                       var selectedVal = ui.item.value;
                       alert(selectedVal);
                   }
            }); 
   });

$('#btnRight').on('click', function (e) {
         popupCenter("movieByactor.php","_blank","400","400");
});
</script>
 </body>
 </html>
Run Code Online (Sandbox Code Playgroud)

这是一个孩子:

<body>
 <script type="text/javascript">

  var selectedVal = parent.window.opener.selectedVal; 
   alert(selectedVal);

 </script>
</body>
Run Code Online (Sandbox Code Playgroud)

javascript php global-variables parent-child

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

在window.location.replace中使用参数

我有以下脚本工作正常:

if(error1 == 1){
    window.alert('You have already signed up!');
    window.location.replace('index.php');
    }
Run Code Online (Sandbox Code Playgroud)

但是当我想使用以下URL而不是index.php时,它不会替换参数:

if(error1 == 1){
    window.alert('You have already signed up!');
    window.location.replace('http://polimovie.deib.polimi.it/Version3/index.php?campaign=".$Campaign_id."&worker=".$Worker_id."');
    }
Run Code Online (Sandbox Code Playgroud)

这段代码重定向我,http://polimovie.deib.polimi.it/Version3/index.php?campaign=.$Campaign_id.&worker=.$Worker_id.而我需要将参数替换为实际数字.

我知道我可以使用php标头,我也在我的PHP代码中使用它,并且这两个工具都很好:

echo "<script>alert('PLEASE SIGN UP FIRST!');window.location = 'http://polimovie.deib.polimi.it/Version3/index.php?campaign=".$Campaign_id."&worker=".$Worker_id."';</script>";
Run Code Online (Sandbox Code Playgroud)

但我想知道如何在window.location.replace中使用参数.

谢谢,

javascript php window.location url-parameters

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

java将列表字符串写入csv文件

我有一些像下面这样的数组字符串(注意每个播放器后面有空格显示不同的行...),

["user1","track1","player1", "user1","track2","player2", "user1","track3","player3", ...] 
Run Code Online (Sandbox Code Playgroud)

我想根据行数(这里的空格)将这个数组分成两部分(几乎相等).因此,例如,如果此数组中有40个空格,我需要将从第一行到第二行(第20行)的行存储在一个文件中(让我们称之为文件A)并将其余部分放在文件B中.我可以划分arraylist,但我无法在CSV文件中以正确的方式编写它.

这是我的代码:

public static void main(String[] args) throws java.lang.Exception { 
BufferedReader userlines = new BufferedReader(new FileReader("/..../usertrackplayer.csv"));       
FileWriter output = new FileWriter(new File("/.../output.csv"));

String uLine = null;    
ArrayList<String> list = new ArrayList<String>();
List<String> arrayList = new ArrayList<String>();
String currentUserId = null;        

while ((uLine = userlines.readLine()) != null) {

    String[] userData = uLine.split(",");
    String userId = userData[0];            
    if (userId.equals(currentUserId)) {
      // Do what ever we need while buffering same userId               
    }
    else{
        list.add(uLine);
        int division = (int) …
Run Code Online (Sandbox Code Playgroud)

java csv arrays writer

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